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-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 25 May 2012 17:29:36 +0200
From:	Lukas Czerner <lczerner@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	linux-fsdevel@...r.kernel.org, mbroz@...hat.com,
	Lukas Czerner <lczerner@...hat.com>,
	Al Viro <viro@...iv.linux.org.uk>
Subject: [PATCH 2/2] vfs: Do not copy_tree() unnecessarily while mounting

While mounting propagate_mnt() would walk through propagation tree
cloning the mount for every every mount the root propagates to.
Even for mounts which parents are not parents of the directory you're
trying to mount to.

Then before the propagate_mnt() is left it will clean the unneeded
cloned mounts (those which parent root is not parent of your new mount
point).

I think this whole operation is unnecessary and can be avoided by
skipping the copy_tree() if the propagated mount root is not
subdirectory of the directory you're mounting to. Such cloned mount
would be cleaned up later anyway.

Signed-off-by: Lukas Czerner <lczerner@...hat.com>
Cc: Al Viro <viro@...iv.linux.org.uk>
---
 fs/pnode.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/pnode.c b/fs/pnode.c
index ab5fa9e..3ebf63d 100644
--- a/fs/pnode.c
+++ b/fs/pnode.c
@@ -237,22 +237,22 @@ int propagate_mnt(struct mount *dest_mnt, struct dentry *dest_dentry,
 
 		source =  get_source(m, prev_dest_mnt, prev_src_mnt, &type);
 
-		if (!(child = copy_tree(source, source->mnt.mnt_root, type))) {
-			ret = -ENOMEM;
-			list_splice(tree_list, tmp_list.prev);
-			goto out;
-		}
-
 		if (is_subdir(dest_dentry, m->mnt.mnt_root)) {
+			if (!(child = copy_tree(source,
+						source->mnt.mnt_root, type))) {
+				ret = -ENOMEM;
+				list_splice(tree_list, tmp_list.prev);
+				goto out;
+			}
+
 			mnt_set_mountpoint(m, dest_dentry, child);
 			list_add_tail(&child->mnt_hash, tree_list);
-		} else {
+		} else
 			/*
 			 * This can happen if the parent mount was bind mounted
 			 * on some subdirectory of a shared/slave mount.
 			 */
-			list_add_tail(&child->mnt_hash, &tmp_list);
-		}
+			continue;
 		prev_dest_mnt = m;
 		prev_src_mnt  = child;
 	}
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ