Re: [PATCH v5 7/8] vfs: Replace security_sb_mount/security_move_mount with granular hooks

From
Christian Brauner <brauner@kernel.org>
Date
2026-06-19 10:17:59
Also in
linux-fsdevel, selinux
Reply to
Christian Brauner, 2026-06-18
On Thu, Jun 18, 2026 at 04:02:22PM +0200, Christian Brauner wrote:
On 2026-06-18 18:56:42+08:00, Song Liu wrote:
quoted
On Wed, Jun 17, 2026 at 9:53 PM Christian Brauner [off-list ref] wrote:
quoted
On Thu, May 28, 2026 at 11:26:06AM -0700, Song Liu wrote:
[...]
quoted
quoted
This again is racy as it is called outside of the namespace semaphore:

        err = security_mount_bind(&old_path, path, recurse);
        if (err)
                return err;

        if (mnt_ns_loop(old_path.dentry))
                return -EINVAL;

        LOCK_MOUNT(mp, path);
        if (IS_ERR(mp.parent))
                return PTR_ERR(mp.parent);

After LOCK_MOUNT @path might point to a completely different mount then
the one you performed your security checks on.
I thought we agreed at LSF/MM/BPF 2026 to add the LSM hooks
before taking namespace semaphore, so that it is possible for LSMs
to defend against DoS attacks on namespace semaphore? Did I
miss/misunderstand something?
I think there was a misunderstanding. What I pointed out was that it's a
trade-off. If we do call security hooks under the namespace semaphore or
mount lock than anything that's called under there must take care to not
cause deadlocks - which is especially easy to do with mount lock and
even with the namespace semaphore it may get hairy (automounts etc). The
dos thing is another worry but if an LSM does stupid things we tell it
to not do stupid things and to go away.

But as the hooks are done right now they are meaningless from a security
perspective. You might have a policy that allows mounting on dentry_a
and deny mounting on dentry_b: before LOCK_MOUNT*() you may see dentry_a
and allow the mount but after LOCK_MOUNT*() someone raced you and shoved
a dentry_b mount onto dentry_b and now you allow overmounting dentry_b
*a dentry_b mount onto dentry_a
Thread (15 messages) 15 messages, 2 authors, last reply 2026-06-19
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help