Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] ve: commit message omits override_ve() VE-switching refusal
  rules
- [Low] ve: feature_capable() ignores overrided_ve while ve_capable()
  honours it
--

commit 5277cbabde9ed3d2f2cb580c3e77aa427fe5adf8
Author: Vladimir Riabchun <[email protected]>

ve: Introduce override_ve/revert_ve helpers

This adds override_ve() and revert_ve(), which mirror override_creds() and 
revert_creds(). It also adds a task->overrided_ve field that ve_capable() and 
ve_capable_noaudit() now consult.

> ve: Introduce override_ve/revert_ve helpers
>
> These helpers mirror override_creds/revert_creds and are supposed to
> be used together in cases when VE creds may be stored and later used
> by the different VE task.
>
> To keep task_ve consistent for other users, introduce a separate
> task->overrided_ve field. Nobody should race on it since its
> updates are supposed to go with override_creds, and non-current
> processes shouldn't do this.
>
> ve_capable and friends now use overrided_ve field if it
> is non-NULL.
>
> This field is not supposed to be inherited via fork, so a check
> for non-NULL overrided_ve was added in fork path.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-142405
> Signed-off-by: Vladimir Riabchun <[email protected]>

[Severity: Low]
As reported by Konstantin Khorenko on v5 [1], the message doesn't describe
what override_ve() allows and refuses. A task inside a container that
asks for any VE other than its own gets ERR_PTR(-EPERM) and a ratelimited
pr_err. Only a host (super-VE) task may switch to an arbitrary VE. The
message also doesn't say that dup_task_struct() now warns if a task forks
while an override is active. Could the message spell out these rules?

> diff --git a/kernel/capability.c b/kernel/capability.c
> --- a/kernel/capability.c
> +++ b/kernel/capability.c
> @@ -406,10 +407,11 @@ bool ve_capable(int cap)
>  bool ve_capable_noaudit(int cap)
>  {
>       struct cred *cred;
> +     struct ve_struct *ve = current->overrided_ve ?: get_exec_env();
>       bool ret;
>
>       rcu_read_lock();
> -     cred = get_exec_env()->init_cred;
> +     cred = ve->init_cred;

[Severity: Low]
Should feature_capable() be updated as well? It still tests
get_exec_env()->features and then calls ve_capable(). Inside an
override_ve() section the feature bit is then read from the task's real VE,
while the capability check uses overrided_ve->init_cred. If the real VE
lacks the feature bit, the fallback capable(cap) runs and the override is
ignored. No in-tree caller was found that reaches this from an override
section, so this is an inconsistency in semantics rather than a demonstrated
failure.

[1] 
https://lore.kernel.org/r/179448942112.4060562.12799497421042932533.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

Reply via email to