Re: [GIT PULL] vfs mount

Christian Brauner
2025-04-03T19:55:52Z

[-- Attachment #1: Type: text/plain, Size: 1209 bytes --]

On Thu, Apr 03, 2025 at 09:45:59PM +0200, Christian Brauner wrote:
> On Thu, Apr 03, 2025 at 12:18:45PM -0700, Linus Torvalds wrote:
> > On Thu, 3 Apr 2025 at 11:25, Leon Romanovsky <leon@kernel.org> wrote:
> > > >
> > > > - scoped_guard(rwsem_read, &namespace_sem)
> > > > + guard(rwsem_read, &namespace_sem);
> > >
> > > I'm looking at Linus's master commit a2cc6ff5ec8f ("Merge tag
> > > 'firewire-updates-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394")
> > > and guard is declared as macro which gets only one argument: include/linux/cleanup.h
> > > 318 #define guard(_name) \
> > > 319 CLASS(_name, __UNIQUE_ID(guard))
> >
> > Christian didn't test his patch, obviously.
>
> Yes, I just sent this out as "I get why this happens." after my
> screaming "dammit" moment. Sorry that I didn't make this clear. I had a
> pretty strong "ffs" 10 minutes after I had waded through the overlayfs
> code I added without being able to figure out how the fsck this could've
> happened. In any case, there's the obviously correct version now sitting
> in the tree and it's seen testing obviously.

I'll also append it here just in case you want to apply it right now.

[-- Attachment #2: v2-0001-fs-actually-hold-the-namespace-semaphore.patch --]
[-- Type: text/x-diff, Size: 915 bytes --]

From f5ff87a84a8803eeb4b344b9a496e7060787b42a Mon Sep 17 00:00:00 2001
From: Christian Brauner <brauner@kernel.org>
Date: Thu, 3 Apr 2025 16:43:50 +0200
Subject: [PATCH v2] fs: actually hold the namespace semaphore

Don't use a scoped guard use a regular guard to make sure that the
namespace semaphore is held across the whole function.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
fs/namespace.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 16292ff760c9..14935a0500a2 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2478,7 +2478,8 @@ struct vfsmount *clone_private_mount(const struct path *path)
struct mount *old_mnt = real_mount(path->mnt);
struct mount *new_mnt;

- scoped_guard(rwsem_read, &namespace_sem)
+ guard(rwsem_read)(&namespace_sem);
+
if (IS_MNT_UNBINDABLE(old_mnt))
return ERR_PTR(-EINVAL);

--
2.47.2