OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Vladimir Riabchun <vladimir.riabchun@virtuozzo.com>
To: vasileios.almpanis@virtuozzo.com, ptikhomirov@virtuozzo.com,
	Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v8 2/6] ve: Introduce override_ve/revert_ve helpers
Date: Mon, 16 Nov 2026 21:05:25 +0100	[thread overview]
Message-ID: <5a08a51d-4262-45a0-87a8-c97a2d5df9a1@virtuozzo.com> (raw)
In-Reply-To: <010701a1e5d43771-f7036827-225f-46e6-9cc1-7988f5626888-000000@eu-central-1.amazonses.com>



On 11/16/26 20:27, no-reply@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@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@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

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  reply	other threads:[~2026-11-16 20:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 19:20 [Devel] [PATCH hci-8.1 v8 0/6] Fix kernel crash in overlayfs Vladimir Riabchun
2026-11-16 19:20 ` [Devel] [PATCH hci-8.1 v8 1/6] ve: Remove STOPPED state Vladimir Riabchun
2026-11-16 19:25   ` no-reply
2026-11-16 19:20 ` [Devel] [PATCH hci-8.1 v8 2/6] ve: Introduce override_ve/revert_ve helpers Vladimir Riabchun
2026-11-16 19:27   ` no-reply
2026-11-16 20:05     ` Vladimir Riabchun [this message]
2026-11-16 19:20 ` [Devel] [PATCH hci-8.1 v8 3/6] ve: Defer ve creds drop until ve is completely destroyed Vladimir Riabchun
2026-11-16 19:27   ` no-reply
2026-11-16 19:20 ` [Devel] [PATCH hci-8.1 v8 4/6] ovl: Keep creator VE in overlayfs superblock Vladimir Riabchun
2026-11-16 19:28   ` no-reply
2026-11-17 14:49   ` Konstantin Khorenko
2026-11-16 19:20 ` [Devel] [PATCH hci-8.1 v8 5/6] ovl: Fix leaking fd references in ovl_copyfile Vladimir Riabchun
2026-11-16 19:28   ` no-reply
2026-11-16 20:03     ` Vladimir Riabchun
2026-11-16 19:20 ` [Devel] [PATCH hci-8.1 v8 6/6] ve/overlayfs: Override VE together with creds Vladimir Riabchun
2026-11-16 19:36   ` no-reply
2026-11-16 20:03     ` Vladimir Riabchun
2026-11-17 14:49 ` [Devel] [PATCH hci-8.1 v8 0/6] Fix kernel crash in overlayfs Konstantin Khorenko
2026-11-17 14:49 ` Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5a08a51d-4262-45a0-87a8-c97a2d5df9a1@virtuozzo.com \
    --to=vladimir.riabchun@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    --cc=ptikhomirov@virtuozzo.com \
    --cc=vasileios.almpanis@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox