Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Low] ve: commit message omits ve_capable() change and override_ve() rules - [Low] ve: override_ve() error path reads ve_name(new_ve) with no pin against ve_offline() --
commit 1ff80fe27a47be85961240ab0b7e9287052ee68d Author: Vladimir Riabchun <[email protected]> ve: Introduce override_ve/revert_ve helpers This commit adds override_ve() and revert_ve() helpers, which mirror override_creds() and revert_creds(). It also adds a task->overrided_ve field. ve_capable() and ve_capable_noaudit() now use that field, and dup_task_struct() clears it on fork. > diff --git a/include/linux/ve.h b/include/linux/ve.h > --- a/include/linux/ve.h > +++ b/include/linux/ve.h > @@ -295,6 +295,30 @@ static inline struct vdso_image *ve_get_vdso_64(struct > ve_struct *ve) > return ve->vdso_64; > } > > +static inline struct ve_struct *override_ve(struct ve_struct *new_ve) > +{ > + struct ve_struct *old_ve = current->overrided_ve; > + > + /* CT tasks are not supposed to switch VE context, this is a breach */ > + if (new_ve != get_exec_env() && !ve_is_super(get_exec_env())) { > + pr_err_ratelimited("Invalid VE override: %s -> %s\n", > + ve_name(get_exec_env()), > + VE_IS_RUNNING(new_ve) ? ve_name(new_ve) : "(dead VE)"); [Severity: Low] As reported by Konstantin Khorenko on v5 [1], can this read freed memory? ve_name(new_ve) is read with no lock, RCU section or reference. The VE_IS_RUNNING() check is racy, and ve_offline() frees ve->ve_name with a plain kfree() and no RCU. The get_ve() reference held by the caller keeps the ve_struct alive, but not the name string. The message is ratelimited and the window is narrow. Would it be better to stop printing ve_name(new_ve) here, as requested on v5? > + return ERR_PTR(-EPERM); > + } > + > + current->overrided_ve = new_ve; > + return old_ve; > +} [ ... ] > diff --git a/kernel/capability.c b/kernel/capability.c > --- a/kernel/capability.c > +++ b/kernel/capability.c > @@ -389,10 +389,11 @@ EXPORT_SYMBOL(ns_capable); > bool ve_capable(int cap) > { > struct cred *cred; > + struct ve_struct *ve = current->overrided_ve ?: get_exec_env(); > bool ret; [Severity: Low] As reported by Konstantin Khorenko on v5 [1], the commit message never mentions that ve_capable() and ve_capable_noaudit() now check capabilities against current->overrided_ve instead of get_exec_env(). It also does not say which VE switches override_ve() allows, and that it refuses a switch by a CT task to a different VE with -EPERM. Could the message describe these behaviour changes? [1] https://lore.kernel.org/r/179448942112.4060562.12042466360723083159.b4-review@b4 -- Sashiko AI review ยท https://sashiko.vzint.dev/#/patchset/[email protected]?part=2 _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
