OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Vladimir Riabchun <vladimir.riabchun@virtuozzo.com>
To: ptikhomirov@virtuozzo.com, Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v4 2/5] ve: Introduce override_ve/revert_ve helpers
Date: Mon, 9 Nov 2026 20:52:44 +0100	[thread overview]
Message-ID: <ea2e4fd3-d268-445f-9385-758c17774dbb@virtuozzo.com> (raw)
In-Reply-To: <010701a1c1d68b6b-d2b45261-2206-45c7-b6f4-a5200bbce44c-000000@eu-central-1.amazonses.com>



On 11/9/26 20:43, no-reply@sashiko.virtuozzo.com wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] ve: override_ve() uses a non-ratelimited WARN_ON as its permission check
> --
> 
> Commit dab91ee458061d579a92288ba48a09c48c12df09
> Author: Vladimir Riabchun <vladimir.riabchun@virtuozzo.com>
> 
> ve: Introduce override_ve/revert_ve helpers
> 
> This adds override_ve() and revert_ve() helpers that mirror
> override_creds() and revert_creds(). It also adds a task->overrided_ve
> field, which ve_capable() and ve_capable_noaudit() now consult, and a
> check in dup_task_struct() that the field is not inherited on fork.
> 
> Link: https://virtuozzo.atlassian.net/browse/VSTOR-142405
> 
>> 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,26 @@ 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 (WARN_ON(new_ve != get_exec_env() && !ve_is_super(get_exec_env())))
>> +		return ERR_PTR(-EPERM);
> 
> [Severity: Low]
> Can this WARN_ON fire on a legitimate path? override_ve() is called from
> ovl_override_creds() with ofs->creator_ve, which is fixed at mount time
> in ovl_fill_super() as get_ve(get_exec_env()).

This is a security issue and we really don't want to
allow this. Just don't make an overlayfs in a CT over an overlayfs
from another, this is weird.

> 
> If a container task reaches an overlay whose creator VE is not its own VE
> (for example an overlay mounted by the host and exposed to the container,
> perhaps through a bind mount), the condition
> new_ve != get_exec_env() && !ve_is_super(get_exec_env())
> is true on every lookup, permission check, getattr, readdir and so on.
> 
> Each of those operations would then log a warning splat and fail with
> -EPERM, where they previously succeeded. I could not confirm from the
> repository that such exposure actually occurs, so this depends on whether
> it is reachable.
> 
> The WARN_ON is neither _ONCE nor ratelimited, so repeated failures can
> flood the log, and with panic_on_warn set the system would panic. Would
> a ratelimited or one-time warning, or no warning and just the -EPERM
> return, be more appropriate for a permission check that callers already
> handle?

We want to see a call trace for debugging purposes in such case.
I think WARN_ON is fine. User should see a bunch of warnings that
something is going terribly wrong and run to us and report it.

> 
>> +
>> +	current->overrided_ve = new_ve;
>> +	return old_ve;
>> +}
> 
> [ ... ]
> 

-- 
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-09 19:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 19:35 [Devel] [PATCH hci-8.1 v4 0/5] Fix kernel crash in overlayfs Vladimir Riabchun
2026-11-09 19:35 ` [Devel] [PATCH hci-8.1 v4 1/5] ve: Remove STOPPED state Vladimir Riabchun
2026-11-09 19:41   ` no-reply
2026-11-09 19:36 ` [Devel] [PATCH hci-8.1 v4 2/5] ve: Introduce override_ve/revert_ve helpers Vladimir Riabchun
2026-11-09 19:43   ` no-reply
2026-11-09 19:52     ` Vladimir Riabchun [this message]
2026-11-09 19:36 ` [Devel] [PATCH hci-8.1 v4 3/5] ve: Defer ve context drop until ve is completely destroyed Vladimir Riabchun
2026-11-09 19:44   ` no-reply
2026-11-09 19:36 ` [Devel] [PATCH hci-8.1 v4 4/5] ovl: Keep creator VE in overlayfs superblock Vladimir Riabchun
2026-11-09 19:45   ` no-reply
2026-11-09 19:36 ` [Devel] [PATCH hci-8.1 v4 5/5] ve/overlayfs: Override VE together with creds Vladimir Riabchun
2026-11-09 19:49   ` no-reply
2026-11-09 19:56     ` Vladimir Riabchun

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=ea2e4fd3-d268-445f-9385-758c17774dbb@virtuozzo.com \
    --to=vladimir.riabchun@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    --cc=ptikhomirov@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