From: Christian Brauner <brauner@kernel.org>
To: Song Liu <songliubraving@meta.com>
Cc: Paul Moore <paul@paul-moore.com>,
Al Viro <viro@zeniv.linux.org.uk>, Song Liu <song@kernel.org>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-security-module@vger.kernel.org"
<linux-security-module@vger.kernel.org>,
"apparmor@lists.ubuntu.com" <apparmor@lists.ubuntu.com>,
"selinux@vger.kernel.org" <selinux@vger.kernel.org>,
"tomoyo-users_en@lists.sourceforge.net"
<tomoyo-users_en@lists.sourceforge.net>,
"tomoyo-users_ja@lists.sourceforge.net"
<tomoyo-users_ja@lists.sourceforge.net>,
Kernel Team <kernel-team@meta.com>,
"andrii@kernel.org" <andrii@kernel.org>,
"eddyz87@gmail.com" <eddyz87@gmail.com>,
"ast@kernel.org" <ast@kernel.org>,
"daniel@iogearbox.net" <daniel@iogearbox.net>,
"martin.lau@linux.dev" <martin.lau@linux.dev>,
"jack@suse.cz" <jack@suse.cz>,
"kpsingh@kernel.org" <kpsingh@kernel.org>,
"mattbobrowski@google.com" <mattbobrowski@google.com>,
"amir73il@gmail.com" <amir73il@gmail.com>,
"repnop@google.com" <repnop@google.com>,
"jlayton@kernel.org" <jlayton@kernel.org>,
"josef@toxicpanda.com" <josef@toxicpanda.com>,
"mic@digikod.net" <mic@digikod.net>,
"gnoack@google.com" <gnoack@google.com>,
"m@maowtm.org" <m@maowtm.org>,
"john.johansen@canonical.com" <john.johansen@canonical.com>,
"john@apparmor.net" <john@apparmor.net>,
"stephen.smalley.work@gmail.com"
<stephen.smalley.work@gmail.com>,
"omosnace@redhat.com" <omosnace@redhat.com>,
"takedakn@nttdata.co.jp" <takedakn@nttdata.co.jp>,
"penguin-kernel@i-love.sakura.ne.jp"
<penguin-kernel@i-love.sakura.ne.jp>,
"enlightened@chromium.org" <enlightened@chromium.org>
Subject: Re: [RFC] vfs: security: Parse dev_name before calling security_sb_mount
Date: Mon, 14 Jul 2025 10:45:22 +0200 [thread overview]
Message-ID: <20250714-ansonsten-shrimps-b4df1566f016@brauner> (raw)
In-Reply-To: <4EE690E2-4276-41E6-9D8C-FBF7E90B9EB3@meta.com>
On Fri, Jul 11, 2025 at 04:22:52PM +0000, Song Liu wrote:
>
>
> > On Jul 11, 2025, at 2:36 AM, Christian Brauner <brauner@kernel.org> wrote:
>
> [...]
>
> >>>
> >> To make sure I understand the comment. By “new mount api”, do you mean
> >> the code path under do_new_mount()?
> >
> > fsopen()
> > fsconfig()
> > fsmount()
> > open_tree()
> > open_tree_attr()
> > move_mount()
> > statmount()
> > listmount()
> >
> > I think that's all.
>
> Thanks for the clarification and pointer!
>
> >
> >>
> >>> My recommendation is make a list of all the currently supported
> >>> security_*() hooks in the mount code (I certainly don't have them in my
> >>> head). Figure out what each of them allow to mediate effectively and how
> >>> the callchains are related.
> >>>
> >>> Then make a proposal how to replace them with something that a) doesn't
> >>> cause regressions which is probably something that the LSMs care about
> >>> and b) that covers the new mount API sufficiently to be properly
> >>> mediated.
> >>>
> >>> I'll happily review proposals. Fwiw, I'm pretty sure that this is
> >>> something that Mickael is interested in as well.
> >>
> >> So we will consider a proper redesign of LSM hooks for mount syscalls,
> >> but we do not want incremental improvements like this one. Do I get
> >> the direction right?
> >
> > If incremental is workable then I think so yes. But it would be great to
> > get a consistent picture of what people want/need.
>
> In short term, we would like a way to get struct path of dev_name for
You scared me for a second. By "dev_name" you mean the source path.
> bind mount. AFAICT, there are a few options:
>
> 1. Introduce bpf_kern_path kfunc.
> 2. Add new hook(s), such as [1].
> 3. Something like this patch.
>
> [1] https://lore.kernel.org/linux-security-module/20250110021008.2704246-1-enlightened@chromium.org/
>
> Do you think we can ship one of them?
If you place a new security hook into __do_loopback() the only thing
that I'm not excited about is that we're holding the global namespace
semaphore at that point. And I want to have as little LSM hook calls
under the namespace semaphore as possible.
If you have 1000 containers each calling into
security_something_something_bind_mount() and then you do your "walk
upwards towards the root stuff" and that root is 100000 directories away
you've introduced a proper DOS or at least a severe new bottleneck into
the system. And because of mount namespace propagation that needs to be
serialized across all mount namespaces the namespace semaphore isn't
something we can just massage away.
next prev parent reply other threads:[~2025-07-14 8:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-08 23:05 [RFC] vfs: security: Parse dev_name before calling security_sb_mount Song Liu
2025-07-09 10:24 ` Al Viro
2025-07-09 15:19 ` Paul Moore
2025-07-09 17:06 ` Song Liu
2025-07-10 11:46 ` Christian Brauner
2025-07-10 17:00 ` Song Liu
2025-07-11 9:36 ` Christian Brauner
2025-07-11 16:22 ` Song Liu
2025-07-14 8:45 ` Christian Brauner [this message]
2025-07-14 15:10 ` Song Liu
2025-07-15 10:18 ` Christian Brauner
2025-07-15 22:31 ` Song Liu
2025-07-16 8:31 ` Christian Brauner
2025-07-16 17:12 ` Song Liu
2025-07-11 23:09 ` Song Liu
2025-07-10 21:40 ` Paul Moore
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=20250714-ansonsten-shrimps-b4df1566f016@brauner \
--to=brauner@kernel.org \
--cc=amir73il@gmail.com \
--cc=andrii@kernel.org \
--cc=apparmor@lists.ubuntu.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=enlightened@chromium.org \
--cc=gnoack@google.com \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=john.johansen@canonical.com \
--cc=john@apparmor.net \
--cc=josef@toxicpanda.com \
--cc=kernel-team@meta.com \
--cc=kpsingh@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=m@maowtm.org \
--cc=martin.lau@linux.dev \
--cc=mattbobrowski@google.com \
--cc=mic@digikod.net \
--cc=omosnace@redhat.com \
--cc=paul@paul-moore.com \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=repnop@google.com \
--cc=selinux@vger.kernel.org \
--cc=song@kernel.org \
--cc=songliubraving@meta.com \
--cc=stephen.smalley.work@gmail.com \
--cc=takedakn@nttdata.co.jp \
--cc=tomoyo-users_en@lists.sourceforge.net \
--cc=tomoyo-users_ja@lists.sourceforge.net \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).