Hi,
From: Christian Brauner brauner@kernel.org Date: Fri, 12 Sep 2025 13:52:41 +0200 [...]
@@ -4275,7 +4197,7 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns, if (pwdmnt) mntput(pwdmnt);
- mnt_ns_tree_add(new_ns);
- ns_tree_add_raw(new_ns);
When copy_tree() fails, new_ns's rb tree could be empty,
guard(namespace_excl)(); ... new = copy_tree(old, old->mnt.mnt_root, copy_flags); if (IS_ERR(new)) { emptied_ns = new_ns; return ERR_CAST(new); }
which seems to trigger this warning in __ns_tree_remove().
VFS_WARN_ON_ONCE(RB_EMPTY_NODE(&ns->ns_tree_node));
stack trace captured by syzbot:
WARNING: kernel/nstree.c:115 at __ns_tree_remove+0x28d/0x330 kernel/nstree.c:115, CPU#0: syz.5.2042/14092 Modules linked in: CPU: 0 UID: 0 PID: 14092 Comm: syz.5.2042 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/18/2025 RIP: 0010:__ns_tree_remove+0x28d/0x330 kernel/nstree.c:115 Code: 0f 85 a4 00 00 00 48 8b 04 24 ff 00 48 8b 7c 24 18 48 83 c4 30 5b 41 5c 41 5d 41 5e 41 5f 5d e9 e9 b4 f8 09 e8 94 f1 31 00 90 <0f> 0b 90 e9 cc fd ff ff e8 86 f1 31 00 90 0f 0b 90 e9 ee fd ff ff RSP: 0018:ffffc9001040faa8 EFLAGS: 00010287 RAX: ffffffff818de18c RBX: ffff8880565d4620 RCX: 0000000000080000 RDX: ffffc9001ca51000 RSI: 00000000000003f8 RDI: 00000000000003f9 RBP: dffffc0000000000 R08: ffffffff8e1eff53 R09: 1ffffffff1c3dfea R10: dffffc0000000000 R11: fffffbfff1c3dfeb R12: ffff8880565d4620 R13: 1ffff1100acba8c3 R14: ffff8880565d4600 R15: ffffffff8e1ea7c0 FS: 00007fba829d56c0(0000) GS:ffff8881259e0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000110c3b8de5 CR3: 000000004bb54000 CR4: 00000000003526f0 Call Trace: <TASK> mnt_ns_tree_remove fs/namespace.c:165 [inline] free_mnt_ns+0xd1/0x110 fs/namespace.c:4074 namespace_unlock+0x529/0x760 fs/namespace.c:1710 class_namespace_excl_destructor fs/namespace.c:96 [inline] copy_mnt_ns+0x6e0/0x870 fs/namespace.c:4180 create_new_namespaces+0xd1/0x720 kernel/nsproxy.c:78 unshare_nsproxy_namespaces+0x11c/0x170 kernel/nsproxy.c:218 ksys_unshare+0x4c8/0x8c0 kernel/fork.c:3144 __do_sys_unshare kernel/fork.c:3215 [inline] __se_sys_unshare kernel/fork.c:3213 [inline] __x64_sys_unshare+0x38/0x50 kernel/fork.c:3213 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fba8478eba9 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fba829d5038 EFLAGS: 00000246 ORIG_RAX: 0000000000000110 RAX: ffffffffffffffda RBX: 00007fba849d6180 RCX: 00007fba8478eba9 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000028060400 RBP: 00007fba84811e19 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fba849d6218 R14: 00007fba849d6180 R15: 00007ffe311606c8 </TASK>