lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250514002650.118278-1-kazuma-kondo@nec.com>
Date: Wed, 14 May 2025 00:25:58 +0000
From: KONDO KAZUMA(近藤 和真)
	<kazuma-kondo@....com>
To: "viro@...iv.linux.org.uk" <viro@...iv.linux.org.uk>, "brauner@...nel.org"
	<brauner@...nel.org>, "jack@...e.cz" <jack@...e.cz>
CC: "mike@...ynton.com" <mike@...ynton.com>, "miklos@...redi.hu"
	<miklos@...redi.hu>, "amir73il@...il.com" <amir73il@...il.com>,
	"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
	"linux-unionfs@...r.kernel.org" <linux-unionfs@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	KONDO KAZUMA(近藤 和真)
	<kazuma-kondo@....com>
Subject: [PATCH] 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 [1].

  [    4.080134] overlayfs: failed to clone upperpath

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

The commit [1] 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 relaxing the permission check
of clone_private_mount(), similar to [2].

[1] commit db04662e2f4f ("fs: allow detached mounts in clone_private_mount()")
[2] commit 46f5ab762d04 ("fs: relax mount_setattr() permission checks")

Fixes: db04662e2f4f ("fs: allow detached mounts in clone_private_mount()")
Signed-off-by: Kazuma Kondo <kazuma-kondo@....com>
---
 fs/namespace.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 1b466c54a357..277dbf18e160 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2482,17 +2482,13 @@ struct vfsmount *clone_private_mount(const struct path *path)
 	if (IS_MNT_UNBINDABLE(old_mnt))
 		return ERR_PTR(-EINVAL);
 
-	if (mnt_has_parent(old_mnt)) {
+	if (!is_mounted(&old_mnt->mnt))
+		return ERR_PTR(-EINVAL);
+
+	if (mnt_has_parent(old_mnt) || !is_anon_ns(old_mnt->mnt_ns)) {
 		if (!check_mnt(old_mnt))
 			return ERR_PTR(-EINVAL);
 	} else {
-		if (!is_mounted(&old_mnt->mnt))
-			return ERR_PTR(-EINVAL);
-
-		/* Make sure this isn't something purely kernel internal. */
-		if (!is_anon_ns(old_mnt->mnt_ns))
-			return ERR_PTR(-EINVAL);
-
 		/* Make sure we don't create mount namespace loops. */
 		if (!check_for_nsfs_mounts(old_mnt))
 			return ERR_PTR(-EINVAL);
-- 
2.49.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ