ipc: drop the mqueue mount with kern_unmount() on setup failure

mq_init_ns() creates the mqueue mount with fc_mount_longterm(), so its
->mnt_ns is MNT_NS_INTERNAL. When setting up the mqueue or ipc sysctls
or msg_init_ns() fails afterwards, create_ipc_ns() drops it with a plain
mntput(). With ->mnt_ns set that takes the fast path of
mntput_no_expire(). The count drops to zero and nothing ever kills the
mount, so the mount and the mqueue superblock are leaked.

Commit dc55e35f9e ("ipc: Store mqueue sysctls in the ipc namespace")
added the first failure path after mq_init_ns() and never dropped the
mount. Commit 7229d74e5e ("ipc: create_ipc_ns: drop mqueue mount on
sysctl setup failure") tried to fix that with a mntput() but that
doesn't help for a long-term mount.

Use kern_unmount(). free_ipc() open-codes the same thing for a namespace
that made it.

Fixes: dc55e35f9e ("ipc: Store mqueue sysctls in the ipc namespace")
Fixes: 7229d74e5e ("ipc: create_ipc_ns: drop mqueue mount on sysctl setup failure")
Cc: [email protected]
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Christian Brauner (Amutable) <[email protected]>
This commit is contained in:
Christian Brauner committed 2026-10-14 22:08:03 +02:00
1 parent 6e6928b396
commit f0e48172a5
1 file changed
+1 -1
+1 -1
View File
@@ -96,7 +96,7 @@ fail_ipc:
fail_mq_sysctls:
retire_mq_sysctls(ns);
fail_mq_mount:
mntput(ns->mq_mnt);
kern_unmount(ns->mq_mnt);
fail_put:
put_user_ns(ns->user_ns);
ns_common_free(ns);