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 5/5] ve/overlayfs: Override VE together with creds
Date: Mon, 9 Nov 2026 20:56:36 +0100 [thread overview]
Message-ID: <019fc5a2-1da0-41af-bfe4-ff813ed6e4f5@virtuozzo.com> (raw)
In-Reply-To: <010701a1c1dbc46a-09b3db06-4bcb-439b-848f-69df34074a4b-000000@eu-central-1.amazonses.com>
On 11/9/26 20:49, no-reply@sashiko.virtuozzo.com wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] ovl: ovl_override_creds() fails with WARN and -EPERM for CT callers of a foreign-VE overlay
> --
>
> commit 9e04559c3517d9690eb025bf97e30b602d11f4ca
> Author: Vladimir Riabchun <vladimir.riabchun@virtuozzo.com>
>
> ve/overlayfs: Override VE together with creds
>
> This patch changes ovl_override_creds() to also override the VE
> (through override_ve()) using ofs->creator_ve. It returns both the old
> cred and the old VE in a new struct ovl_creds_desc, and converts all
> overlayfs callers to the new ovl_override_creds()/ovl_revert_creds()
> pair. The stated goal is to let a host user access an overlayfs created
> inside a CT without ve_capable() checks failing.
>
> Link: https://virtuozzo.atlassian.net/browse/VSTOR-142405
>
>> diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
>> index f95090f0d29c..d28d572d6099 100644
>> --- a/fs/overlayfs/util.c
>> +++ b/fs/overlayfs/util.c
>
> [ ... ]
>
>> @@ -63,11 +63,27 @@ struct dentry *ovl_workdir(struct dentry *dentry)
>> return ofs->workdir;
>> }
>>
>> -const struct cred *ovl_override_creds(struct super_block *sb)
>> +/* On error no revert is needed. */
>> +int ovl_override_creds(struct super_block *sb, struct ovl_creds_desc *desc)
>> {
>> struct ovl_fs *ofs = OVL_FS(sb);
>>
>> - return override_creds(ofs->creator_cred);
>> + desc->ve = override_ve(ofs->creator_ve);
>> + if (IS_ERR(desc->ve))
>> + return PTR_ERR(desc->ve);
>> +
>> + desc->cred = override_creds(ofs->creator_cred);
>> + return 0;
>> +}
>
> [Severity: Medium]
> Can this turn a previously working access into a WARN plus -EPERM for
> tasks running in a container?
>
> ovl_fill_super() stores ofs->creator_ve = get_ve(get_exec_env()), so
> creator_ve is the VE of the mounting task. Every converted entry point
> (ovl_lookup(), ovl_permission(), ovl_getattr(), ovl_iterate(),
> ovl_open_realfile(), the xattr and copy-up paths) now calls
> ovl_override_creds(), which calls override_ve(ofs->creator_ve).
>
> With CONFIG_VE, override_ve() in include/linux/ve.h does:
>
> if (WARN_ON(new_ve != get_exec_env() && !ve_is_super(get_exec_env())))
> return ERR_PTR(-EPERM);
>
> That condition is true for any non-host task whose VE differs from
> creator_ve. One example is a CT task reaching a host-mounted overlay
> through a bind mount or mount propagation. Another is a CT task reaching
> another CT's overlay. In both cases, ovl_override_creds() returns -EPERM
> and the operation fails.
>
> Before this patch only the creds were swapped, so that access worked.
> Each failure now also emits a WARN backtrace, which is a panic with
> panic_on_warn. Is this reachable from within a container?
>
> The commit message covers only the host-accessing-CT direction and does
> not mention this one. Is it intended that a CT task accessing an overlay
> created in a different VE fails with -EPERM?
>
> If it is intended, would it be better to avoid the WARN_ON backtrace on
> this path, for example by checking the VE relationship in
> ovl_override_creds() before calling override_ve()?
This is the whole idea. We never want to upgrade our privileges,
so this should be restricted.
If this happens - it is either someone trying to use host overlay
mount inside CT, or a CT/kernel is doing something nasty.
Both cases should be reported loudly.
>
> [ ... ]
>
--
Best regards, Riabchun Vladimir
Linux Kernel Developer, Virtuozzo
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
prev parent reply other threads:[~2026-11-09 19:57 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
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 [this message]
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=019fc5a2-1da0-41af-bfe4-ff813ed6e4f5@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