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]
Message-Id: <20210602144630.161982-2-dong.menglong@zte.com.cn>
Date:   Wed,  2 Jun 2021 22:46:28 +0800
From:   menglong8.dong@...il.com
To:     christian.brauner@...ntu.com
Cc:     viro@...iv.linux.org.uk, keescook@...omium.org,
        samitolvanen@...gle.com, johan@...nel.org, ojeda@...nel.org,
        akpm@...ux-foundation.org, dong.menglong@....com.cn,
        masahiroy@...nel.org, joe@...ches.com, hare@...e.de,
        axboe@...nel.dk, jack@...e.cz, tj@...nel.org,
        gregkh@...uxfoundation.org, song@...nel.org, neilb@...e.de,
        brho@...gle.com, mcgrof@...nel.org, palmerdabbelt@...gle.com,
        arnd@...db.de, f.fainelli@...il.com, linux@...musvillemoes.dk,
        wangkefeng.wang@...wei.com, mhiramat@...nel.org,
        rostedt@...dmis.org, vbabka@...e.cz, pmladek@...e.com,
        glider@...gle.com, chris@...isdown.name, ebiederm@...ssion.com,
        jojing64@...il.com, mingo@...nel.org, terrelln@...com,
        geert@...ux-m68k.org, linux-fsdevel@...r.kernel.org,
        linux-kernel@...r.kernel.org, jeyu@...nel.org, bhelgaas@...gle.com,
        josh@...htriplett.org
Subject: [PATCH v4 1/3] init/main.c: introduce function ramdisk_exec_exist()

From: Menglong Dong <dong.menglong@....com.cn>

Introduce the function ramdisk_exec_exist, which is used to check the
exist of 'ramdisk_execute_command'.

To make path lookup follow the mount on '/', use vfs_path_lookup() in
init_eaccess(), and make the filesystem that mounted on '/' as root
during path lookup.

Signed-off-by: Menglong Dong <dong.menglong@....com.cn>
---
 fs/init.c   | 11 +++++++++--
 init/main.c |  7 ++++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/fs/init.c b/fs/init.c
index 5c36adaa9b44..166356a1f15f 100644
--- a/fs/init.c
+++ b/fs/init.c
@@ -112,14 +112,21 @@ int __init init_chmod(const char *filename, umode_t mode)
 
 int __init init_eaccess(const char *filename)
 {
-	struct path path;
+	struct path path, root;
 	int error;
 
-	error = kern_path(filename, LOOKUP_FOLLOW, &path);
+	error = kern_path("/", LOOKUP_DOWN, &root);
 	if (error)
 		return error;
+	error = vfs_path_lookup(root.dentry, root.mnt, filename,
+				LOOKUP_FOLLOW, &path);
+	if (error)
+		goto on_err;
 	error = path_permission(&path, MAY_ACCESS);
+
 	path_put(&path);
+on_err:
+	path_put(&root);
 	return error;
 }
 
diff --git a/init/main.c b/init/main.c
index eb01e121d2f1..1153571ca977 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1522,6 +1522,11 @@ void __init console_on_rootfs(void)
 	fput(file);
 }
 
+bool __init ramdisk_exec_exist(void)
+{
+	return init_eaccess(ramdisk_execute_command) == 0;
+}
+
 static noinline void __init kernel_init_freeable(void)
 {
 	/*
@@ -1568,7 +1573,7 @@ static noinline void __init kernel_init_freeable(void)
 	 * check if there is an early userspace init.  If yes, let it do all
 	 * the work
 	 */
-	if (init_eaccess(ramdisk_execute_command) != 0) {
+	if (!ramdisk_exec_exist()) {
 		ramdisk_execute_command = NULL;
 		prepare_namespace();
 	}
-- 
2.32.0.rc0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ