diff options
author | Christian Brauner <brauner@kernel.org> | 2025-02-21 14:13:02 +0100 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2025-03-04 09:29:52 +0100 |
commit | 043bc81efbfc5580ecd9da76118722649205f30a (patch) | |
tree | 05676085dd7d81ba7df3c08392ba5e3796d03d60 /fs/namespace.c | |
parent | 2f576220cd8129a303ef4bac4b08e3937c42eff8 (diff) |
fs: add assert for move_mount()
After we've attached a detached mount tree the anonymous mount namespace
must be empty. Add an assert and make this assumption explicit.
Link: https://lore.kernel.org/r/20250221-brauner-open_tree-v1-3-dbcfcb98c676@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/namespace.c')
-rw-r--r-- | fs/namespace.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index 8ca28737f4ee..c9670a198b50 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -3423,10 +3423,13 @@ static int do_move_mount(struct path *old_path, struct path *new_path, out: unlock_mount(mp); if (!err) { - if (attached) + if (attached) { mntput_no_expire(parent); - else + } else { + /* Make sure we notice when we leak mounts. */ + VFS_WARN_ON_ONCE(!mnt_ns_empty(ns)); free_mnt_ns(ns); + } } return err; } |