Skip to contentSkip to conversation

fs: don't try and remove empty rbtree node

PATCH New Christian Brauner 1 participant 1 message Oct 16, 2024

Subsystems (2)
lore
Share & tools
lore

Christian Brauner

author maintainer
#0 lore raw

PATCH 1/1 fs: don't try and remove empty rbtree node

When copying a namespace we won't have added the new copy into the namespace rbtree until after the copy succeeded. Calling free_mnt_ns() will try to remove the copy from the rbtree which is invalid. Simply free the namespace skeleton directly.

Fixes 1901c92497bd ("fs: keep an index of current mount namespaces")
Cc [email protected] # v6.11+

---
In vfs.fixes unless I hear objections.

---
 fs/namespace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/namespace.c +3 -1
index 93c377816d75..d26f5e6d2ca3 100644
@@ -3944,7 +3944,9 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
 	new = copy_tree(old, old->mnt.mnt_root, copy_flags);
 	if (IS_ERR(new)) {
 		namespace_unlock();
-		free_mnt_ns(new_ns);
+		ns_free_inum(&new_ns->ns);
+		dec_mnt_namespaces(new_ns->ucounts);
+		mnt_ns_release(new_ns);
 		return ERR_CAST(new);
 	}
 	if (user_ns != ns->user_ns) {
Signature · 1 line
2.45.2