]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fs: add assert for move_mount()
authorChristian Brauner <brauner@kernel.org>
Fri, 21 Feb 2025 13:13:02 +0000 (14:13 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 4 Mar 2025 08:29:52 +0000 (09:29 +0100)
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>
fs/namespace.c

index 8ca28737f4ee8dc9f6898e38d51f3b33f352f3a4..c9670a198b507f47b7bb1077d3d55e29441021fa 100644 (file)
@@ -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;
 }