]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fs/namespace: notify pollers of legacy propagation changes
authorGuopeng Zhang <zhangguopeng@kylinos.cn>
Mon, 1 Jun 2026 03:29:11 +0000 (11:29 +0800)
committerChristian Brauner <brauner@kernel.org>
Tue, 30 Jun 2026 11:03:53 +0000 (13:03 +0200)
Changing mount propagation through the legacy mount API changes
user-visible mountinfo contents, including the shared: and master:
optional fields.

The mount_setattr() path already touches the mount namespace after
change_mnt_propagation(), so pollers of /proc/<pid>/mountinfo are woken
when the namespace event changes.

The legacy mount --make-* path also changes propagation through
change_mnt_propagation(), and MOVE_MOUNT_SET_GROUP updates the
propagation relationship of the target mount. Both paths currently
return without touching the affected mount namespace.

As a result, userspace polling /proc/<pid>/mountinfo can miss these
propagation-only changes even though mountinfo has changed.

A simple reproducer that polls /proc/self/mountinfo while changing
propagation shows the inconsistency.

Before this change:

  legacy MS_SHARED: poll ret=0 revents=0x0
  mount_setattr MS_SHARED: poll ret=1 revents=0xa

After this change:

  legacy MS_SHARED: poll ret=1 revents=0xa
  mount_setattr MS_SHARED: poll ret=1 revents=0xa

Fix this by touching the affected mount namespace after successful
propagation changes in do_change_type() and do_set_group().

Signed-off-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
Link: https://patch.msgid.link/20260601032911.940507-1-guopeng.zhang@linux.dev
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/namespace.c

index 3d5cd5bf3b05376c867281541100c6a5e599d387..52ee1e9f4f93ff30d39c8fbf8ffee48833c06dc3 100644 (file)
@@ -2908,6 +2908,9 @@ static int do_change_type(const struct path *path, int ms_flags)
        for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
                change_mnt_propagation(m, type);
 
+       guard(mount_locked_reader)();
+       touch_mnt_namespace(mnt->mnt_ns);
+
        return 0;
 }
 
@@ -3481,6 +3484,10 @@ static int do_set_group(const struct path *from_path, const struct path *to_path
                list_add(&to->mnt_share, &from->mnt_share);
                set_mnt_shared(to);
        }
+
+       guard(mount_locked_reader)();
+       touch_mnt_namespace(to->mnt_ns);
+
        return 0;
 }