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>] [day] [month] [year] [list]
Message-Id: <1623827820-21248-1-git-send-email-yangtiezhu@loongson.cn>
Date:   Wed, 16 Jun 2021 15:17:00 +0800
From:   Tiezhu Yang <yangtiezhu@...ngson.cn>
To:     Luis Chamberlain <mcgrof@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-kernel@...r.kernel.org, Xuefeng Li <lixuefeng@...ngson.cn>
Subject: [RFC PATCH] umh: Check if sub_info->path is exist in call_usermodehelper_setup()

In call_usermodehelper_setup(), if strlen(sub_info->path) is not 0,
but in fact there is no such file, in this case, there is no need to
execute it, set sub_info->path as empty string to avoid meaningless
operations in call_usermodehelper_exec().

Here is an example:
init/do_mounts_initrd.c
static void __init handle_initrd(void)
{
	[...]
	info = call_usermodehelper_setup("/linuxrc", argv, envp_init,
					 GFP_KERNEL, init_linuxrc, NULL, NULL);
	if (!info)
		return;
	call_usermodehelper_exec(info, UMH_WAIT_PROC);
	[...]
}

$ ls /linuxrc
ls: cannot access '/linuxrc': No such file or directory

Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
---
 kernel/umh.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/kernel/umh.c b/kernel/umh.c
index 36c1233..2312cc0 100644
--- a/kernel/umh.c
+++ b/kernel/umh.c
@@ -373,6 +373,17 @@ struct subprocess_info *call_usermodehelper_setup(const char *path, char **argv,
 #else
 	sub_info->path = path;
 #endif
+	if (strlen(sub_info->path) != 0) {
+		struct file *fp;
+
+		fp = filp_open(sub_info->path, O_RDONLY, 0);
+		if (IS_ERR(fp)) {
+			sub_info->path = "";
+			return sub_info;
+		}
+		filp_close(fp, NULL);
+	}
+
 	sub_info->argv = argv;
 	sub_info->envp = envp;
 
-- 
2.1.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ