[Devel] [PATCH hci-8.1 v8 2/6] ve: Introduce override_ve/revert_ve helpers
Vladimir Riabchun
vladimir.riabchun at virtuozzo.com
Mon Nov 16 23:05:25 MSK 2026
On 11/16/26 20:27, no-reply at sashiko.virtuozzo.com wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issues to consider:
> - [Low] ve: feature_capable() ignores overrided_ve while ve_capable()
> honours it
Would be handled in a separate task.
> - [Low] ve: commit message omits override_ve() switching rules and fork
> warning
They are clear from the code. Commit message shouldn't describe code,
it should describe intentions. Code already speaks for itself.
> --
>
> commit 9e8643e97f9ec1b7bd7c8e72db3c7d5655736399
> Author: Vladimir Riabchun <vladimir.riabchun at virtuozzo.com>
>
> ve: Introduce override_ve/revert_ve helpers
>
> This 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() use that field when it is set, and dup_task_struct() warns if it is set on fork.
>
>> diff --git a/include/linux/ve.h b/include/linux/ve.h
>> index 717567775f58..5c9260799db5 100644
>> --- a/include/linux/ve.h
>> +++ b/include/linux/ve.h
>> @@ -295,6 +295,29 @@ 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_name(new_ve));
>> + return ERR_PTR(-EPERM);
>> + }
>
> [Severity: Low]
> As reported by Konstantin Khorenko on v5 [1], the commit message does not describe this switching policy. A CT task 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 another VE. Could the message spell out these rules?
>
> It also does not say why the helpers are needed. The sentence about the fork check does not say that dup_task_struct() only warns when a task forks with an override active.
>
> [ ... ]
>
>> diff --git a/kernel/capability.c b/kernel/capability.c
>> index 34716847c6b8..6de4dcba2283 100644
>> --- 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 no-reply at sashiko.virtuozzo.com on v7 [2], should feature_capable() be updated as well? It still tests get_exec_env()->features, which is the task's real VE:
>
> kernel/capability.c:feature_capable() {
> if (get_exec_env()->features & feature)
> return ve_capable(cap);
> else
> return capable(cap);
> }
>
> During an override_ve() section, the feature test uses the real VE and ve_capable() uses overrided_ve. If the real VE lacks the feature bit, the capable(cap) fallback runs and the override is silently ignored.
>
> This also makes the commit message's "ve_capable and friends" wording broader than what the patch covers.
>
> [1] https://lore.kernel.org/r/179448942112.4060562.12042466360723083159.b4-review@b4
> [2] https://lore.kernel.org/r/010701a1e564cf2a-d6ec1bc0-01f7-4f31-9a2e-03962f66dea4-000000@eu-central-1.amazonses.com
>
--
Best regards, Riabchun Vladimir
Linux Kernel Developer, Virtuozzo
More information about the Devel
mailing list