fs: allow clone_private_mount() for a path on real rootfs
authorKONDO KAZUMA(近藤 和真) <kazuma-kondo@nec.com>
Thu, 15 May 2025 12:18:30 +0000 (12:18 +0000)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 7 Jun 2025 04:41:02 +0000 (00:41 -0400)
commit4954346d80fb047cb78776d9f2ebd6a050f80c5f
treebdd2a68ece3b0751e6b9c8a54d0d2ca1102c2768
parentd8cc0362f918d020ca1340d7694f07062dc30f36
fs: allow clone_private_mount() for a path on real rootfs

Mounting overlayfs with a directory on real rootfs (initramfs)
as upperdir has failed with following message since commit
db04662e2f4f ("fs: allow detached mounts in clone_private_mount()").

  [    4.080134] overlayfs: failed to clone upperpath

Overlayfs mount uses clone_private_mount() to create internal mount
for the underlying layers.

The commit made clone_private_mount() reject real rootfs because
it does not have a parent mount and is in the initial mount namespace,
that is not an anonymous mount namespace.

This issue can be fixed by modifying the permission check
of clone_private_mount() following [1].

Reviewed-by: Christian Brauner <brauner@kernel.org>
Fixes: db04662e2f4f ("fs: allow detached mounts in clone_private_mount()")
Link: https://lore.kernel.org/all/20250514190252.GQ2023217@ZenIV/
Link: https://lore.kernel.org/all/20250506194849.GT2023217@ZenIV/
Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Kazuma Kondo <kazuma-kondo@nec.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namespace.c