mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] fs/namespace: notify pollers of legacy propagation changes
@ 2026-06-01  3:29 Guopeng Zhang
  2026-06-30 11:03 ` Christian Brauner
  0 siblings, 1 reply; 2+ messages in thread
From: Guopeng Zhang @ 2026-06-01  3:29 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner
  Cc: Jan Kara, linux-fsdevel, linux-kernel, Guopeng Zhang

From: Guopeng Zhang <zhangguopeng@kylinos.cn>

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>
---
Changes in v2:
- Use guard(mount_locked_reader)() instead of lock_mount_hash() around
  touch_mnt_namespace(), as suggested by Christian, to avoid forcing
  seqcount readers to retry for propagation-only changes.

v1:
https://lore.kernel.org/all/20260529095441.1744006-1-guopeng.zhang@linux.dev/

 fs/namespace.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/namespace.c b/fs/namespace.c
index 9a66a806a9b8..f01d4b9cf65d 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -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;
 }
 
@@ -3479,6 +3482,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;
 }
 
-- 
2.43.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] fs/namespace: notify pollers of legacy propagation changes
  2026-06-01  3:29 [PATCH v2] fs/namespace: notify pollers of legacy propagation changes Guopeng Zhang
@ 2026-06-30 11:03 ` Christian Brauner
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Brauner @ 2026-06-30 11:03 UTC (permalink / raw)
  To: Alexander Viro, Guopeng Zhang
  Cc: Jan Kara, linux-fsdevel, linux-kernel, Guopeng Zhang

On Mon, 01 Jun 2026 11:29:11 +0800, Guopeng Zhang wrote:
> fs/namespace: notify pollers of legacy propagation changes

Applied to the vfs-7.3.mount branch of the vfs/vfs.git tree.
Patches in the vfs-7.3.mount branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.3.mount

[1/1] fs/namespace: notify pollers of legacy propagation changes
      https://git.kernel.org/vfs/vfs/c/0ae44a20835e


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-30 11:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-01  3:29 [PATCH v2] fs/namespace: notify pollers of legacy propagation changes Guopeng Zhang
2026-06-30 11:03 ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome