From patchwork Sat Jun 27 07:27:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11629289 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 679E2618 for ; Sat, 27 Jun 2020 07:29:29 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 40C552081A for ; Sat, 27 Jun 2020 07:29:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Hk/nCIBz"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Bn9qUHm8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 40C552081A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wiXnS6QtBEdPxp8ZIxJ6XEYXAJD0aqUmsPxDxu/AFv8=; b=Hk/nCIBzb5vVUN2jxjOb8qnPh eDZkXpThO7HsBt3UpUaDvtLGBAix5Kfrp6hk29w1AD4bz76gM36qT4JNUb0wzJaq9koIoNLZmEa0g dfSKYyRW3mfBMaB7fM896oFEVtiKeHH5sKWOnEI38iecedU1Z5IOR0E4ZkKPL+NRmG+FOwQORAlIR 2m29UQWPDR6jcITf6uJMyY05SP8pj0DVk90Lj5IfqqYDHoFk+QHKtPWSF79DOIWjxO4xEizVNOt85 sZYftHUf+/WogSuThf04tjA+oBR4/l4rf/l3KO22vyCbIdiCcyJLO8SAjddS5o4pbw01FdnaYqsNJ tf9pfDKvg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5FB-0000ds-B9; Sat, 27 Jun 2020 07:27:21 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5F9-0000dL-3J for linux-arm-kernel@merlin.infradead.org; Sat, 27 Jun 2020 07:27:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=R3jVFYS/2IFPi5AjMtMLrTJqX+oMKfiLgBtiR94GLYw=; b=Bn9qUHm8sqZ6dyAsMNQeF1SAQK qOz9odcsurHGAun+rlEGFX2naZtghMIA4iNCvdFucZaRqG67gU/BFGYWdiPHinPyemWT8K/dzUAC7 BVUbz/HKtOV9kKV/EgSZKqY2fG0hCnWFXUMTpwq7lDPtzTsQiuS6/bg/Bz8z2nftTY5L3gSJAoAXB Pn6BkPkmQEIAxTwtxkFd96A/2BLD9LG+ifLQGyGRS0vLmAK3CbtSvaZMgTeyuPHWg8dZGx1nW1cWK Rr6EilWm74qOfkU1wwZa8elvp1Pu8z7WO97rTp0rUob9lw/SesjmfOOTo/qO94XivoWoxm2YE1gP5 DmesbwuA==; Received: from [2001:4bb8:184:76e3:595:ba65:ae56:65a6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5F2-0006WL-Mh; Sat, 27 Jun 2020 07:27:15 +0000 From: Christoph Hellwig To: Al Viro Subject: [PATCH 1/5] exec: cleanup the execve wrappers Date: Sat, 27 Jun 2020 09:27:00 +0200 Message-Id: <20200627072704.2447163-2-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200627072704.2447163-1-hch@lst.de> References: <20200627072704.2447163-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, linux-parisc@vger.kernel.org, Arnd Bergmann , Brian Gerst , x86@kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Luis Chamberlain , sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Remove a whole bunch of wrappers that eventually all call __do_execve_file, and consolidate the execvce helpers to: (1) __do_execveat, which is the lowest level helper implementing the actual functionality (2) do_execvat, which is used by all callers that want native pointers (3) do_compat_execve, which is used by all compat syscalls Signed-off-by: Christoph Hellwig --- fs/exec.c | 98 +++++++++++------------------------------ include/linux/binfmts.h | 12 ++--- init/main.c | 7 +-- kernel/umh.c | 16 +++---- 4 files changed, 41 insertions(+), 92 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index e6e8a9a7032784..354fdaa536ae7d 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1815,10 +1815,7 @@ static int exec_binprm(struct linux_binprm *bprm) return 0; } -/* - * sys_execve() executes a new program. - */ -static int __do_execve_file(int fd, struct filename *filename, +static int __do_execveat(int fd, struct filename *filename, struct user_arg_ptr argv, struct user_arg_ptr envp, int flags, struct file *file) @@ -1972,74 +1969,16 @@ static int __do_execve_file(int fd, struct filename *filename, return retval; } -static int do_execveat_common(int fd, struct filename *filename, - struct user_arg_ptr argv, - struct user_arg_ptr envp, - int flags) -{ - return __do_execve_file(fd, filename, argv, envp, flags, NULL); -} - -int do_execve_file(struct file *file, void *__argv, void *__envp) -{ - struct user_arg_ptr argv = { .ptr.native = __argv }; - struct user_arg_ptr envp = { .ptr.native = __envp }; - - return __do_execve_file(AT_FDCWD, NULL, argv, envp, 0, file); -} - -int do_execve(struct filename *filename, - const char __user *const __user *__argv, - const char __user *const __user *__envp) -{ - struct user_arg_ptr argv = { .ptr.native = __argv }; - struct user_arg_ptr envp = { .ptr.native = __envp }; - return do_execveat_common(AT_FDCWD, filename, argv, envp, 0); -} - int do_execveat(int fd, struct filename *filename, const char __user *const __user *__argv, const char __user *const __user *__envp, - int flags) + int flags, struct file *file) { struct user_arg_ptr argv = { .ptr.native = __argv }; struct user_arg_ptr envp = { .ptr.native = __envp }; - return do_execveat_common(fd, filename, argv, envp, flags); -} - -#ifdef CONFIG_COMPAT -static int compat_do_execve(struct filename *filename, - const compat_uptr_t __user *__argv, - const compat_uptr_t __user *__envp) -{ - struct user_arg_ptr argv = { - .is_compat = true, - .ptr.compat = __argv, - }; - struct user_arg_ptr envp = { - .is_compat = true, - .ptr.compat = __envp, - }; - return do_execveat_common(AT_FDCWD, filename, argv, envp, 0); -} - -static int compat_do_execveat(int fd, struct filename *filename, - const compat_uptr_t __user *__argv, - const compat_uptr_t __user *__envp, - int flags) -{ - struct user_arg_ptr argv = { - .is_compat = true, - .ptr.compat = __argv, - }; - struct user_arg_ptr envp = { - .is_compat = true, - .ptr.compat = __envp, - }; - return do_execveat_common(fd, filename, argv, envp, flags); + return __do_execveat(fd, filename, argv, envp, flags, file); } -#endif void set_binfmt(struct linux_binfmt *new) { @@ -2070,7 +2009,7 @@ SYSCALL_DEFINE3(execve, const char __user *const __user *, argv, const char __user *const __user *, envp) { - return do_execve(getname(filename), argv, envp); + return do_execveat(AT_FDCWD, getname(filename), argv, envp, 0, NULL); } SYSCALL_DEFINE5(execveat, @@ -2080,18 +2019,34 @@ SYSCALL_DEFINE5(execveat, int, flags) { int lookup_flags = (flags & AT_EMPTY_PATH) ? LOOKUP_EMPTY : 0; + struct filename *name = getname_flags(filename, lookup_flags, NULL); - return do_execveat(fd, - getname_flags(filename, lookup_flags, NULL), - argv, envp, flags); + return do_execveat(fd, name, argv, envp, flags, NULL); } #ifdef CONFIG_COMPAT +static int do_compat_execve(int fd, struct filename *filename, + const compat_uptr_t __user *__argv, + const compat_uptr_t __user *__envp, + int flags) +{ + struct user_arg_ptr argv = { + .is_compat = true, + .ptr.compat = __argv, + }; + struct user_arg_ptr envp = { + .is_compat = true, + .ptr.compat = __envp, + }; + + return __do_execveat(fd, filename, argv, envp, flags, NULL); +} + COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename, const compat_uptr_t __user *, argv, const compat_uptr_t __user *, envp) { - return compat_do_execve(getname(filename), argv, envp); + return do_compat_execve(AT_FDCWD, getname(filename), argv, envp, 0); } COMPAT_SYSCALL_DEFINE5(execveat, int, fd, @@ -2101,9 +2056,8 @@ COMPAT_SYSCALL_DEFINE5(execveat, int, fd, int, flags) { int lookup_flags = (flags & AT_EMPTY_PATH) ? LOOKUP_EMPTY : 0; + struct filename *name = getname_flags(filename, lookup_flags, NULL); - return compat_do_execveat(fd, - getname_flags(filename, lookup_flags, NULL), - argv, envp, flags); + return do_compat_execve(fd, name, argv, envp, flags); } #endif diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index 4a20b7517dd036..bed702e4b1fbd9 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h @@ -134,13 +134,9 @@ int copy_string_kernel(const char *arg, struct linux_binprm *bprm); extern void set_binfmt(struct linux_binfmt *new); extern ssize_t read_code(struct file *, unsigned long, loff_t, size_t); -extern int do_execve(struct filename *, - const char __user * const __user *, - const char __user * const __user *); -extern int do_execveat(int, struct filename *, - const char __user * const __user *, - const char __user * const __user *, - int); -int do_execve_file(struct file *file, void *__argv, void *__envp); +int do_execveat(int fd, struct filename *filename, + const char __user *const __user *__argv, + const char __user *const __user *__envp, + int flags, struct file *file); #endif /* _LINUX_BINFMTS_H */ diff --git a/init/main.c b/init/main.c index 0ead83e86b5aa2..838950ea7bca22 100644 --- a/init/main.c +++ b/init/main.c @@ -1329,9 +1329,10 @@ static int run_init_process(const char *init_filename) pr_debug(" with environment:\n"); for (p = envp_init; *p; p++) pr_debug(" %s\n", *p); - return do_execve(getname_kernel(init_filename), - (const char __user *const __user *)argv_init, - (const char __user *const __user *)envp_init); + return do_execveat(AT_FDCWD, getname_kernel(init_filename), + (const char __user *const __user *)argv_init, + (const char __user *const __user *)envp_init, + 0, NULL); } static int try_to_run_init_process(const char *init_filename) diff --git a/kernel/umh.c b/kernel/umh.c index 79f139a7ca03c6..7aa9a5817582ca 100644 --- a/kernel/umh.c +++ b/kernel/umh.c @@ -103,15 +103,13 @@ static int call_usermodehelper_exec_async(void *data) commit_creds(new); sub_info->pid = task_pid_nr(current); - if (sub_info->file) { - retval = do_execve_file(sub_info->file, - sub_info->argv, sub_info->envp); - if (!retval) - current->flags |= PF_UMH; - } else - retval = do_execve(getname_kernel(sub_info->path), - (const char __user *const __user *)sub_info->argv, - (const char __user *const __user *)sub_info->envp); + retval = do_execveat(AT_FDCWD, + sub_info->path ? getname_kernel(sub_info->path) : NULL, + (const char __user *const __user *)sub_info->argv, + (const char __user *const __user *)sub_info->envp, + 0, sub_info->file); + if (sub_info->file && !retval) + current->flags |= PF_UMH; out: sub_info->retval = retval; /* From patchwork Sat Jun 27 07:27:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11629297 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D6E890 for ; Sat, 27 Jun 2020 07:29:53 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29A1C2081A for ; Sat, 27 Jun 2020 07:29:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="O1DbdsAD"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="LJR+nKSr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29A1C2081A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WLkBwETFAun8ePIfMZuHjGWUHzonl6bsSLxmYpowquI=; b=O1DbdsADpFw8/11GAuO9Nu2TF M+9BtmkjERUmtWb3lK4D0jys/yp+3pZlGLoOo4XSdVkRljeD9I8k9sxM5rCJncKdduMbJptm4sLqO wEgr+h5//EEAfE+pHeMvnW0RcxhDD6hkwzW+Rfj9z5dCHL6K5p3V7d8xT1VQMo6JOOGzJ8vFvkcdC wy7/3m8n9rW8VY47Fj0p8XGu3971k4wKduSVOoLNy7g1jXU9n980AlfVDnGH+B1AfzWHbBoypwRNX TDwXgNjo1GNXGNv9t3BYn2CjZRc8mDjh6Nem/hJKAdODYGhiE4vTpBKWjjG83FN8b74zaPX7gcW8+ HcSwa/TPg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5FG-0000fB-0B; Sat, 27 Jun 2020 07:27:26 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5FD-0000eK-Az for linux-arm-kernel@merlin.infradead.org; Sat, 27 Jun 2020 07:27:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=iw+9A2JQIHD5fXMGkStguy57SXmkWUmM1s8fo8IbfFs=; b=LJR+nKSr6Fm4nbQGqT2DPportm FlT5UEvfJawrnpykAo+o/P2U7PCVMbZF9AcmebAcQ/W4Bqujpr45utjYsgAQsKWAzv75imJ58RtCL ctokprHM2jeMO5dPOcd/WSZpbMzxPQSSG3XpSbUOWJnRhP/M6HXNt1cb1/FTj4JiNI/wUx1I6Ryht pJjl3ll65pcbkwrtYouQdXYvbkNmtp3sHrJ1HeRfBLgPtP/hnyTAaaj5omPScWUtFhCXlPc9YA42Z ndUX/1e6/jm/GX6stn18VcNsfLUCd1K7PJyTfgZYE3MPERoCYXkw5JWw3W6nqGaFzaBh/ZHG8T54y a1CMG/5Q==; Received: from [2001:4bb8:184:76e3:595:ba65:ae56:65a6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5F9-0006Ww-5C; Sat, 27 Jun 2020 07:27:21 +0000 From: Christoph Hellwig To: Al Viro Subject: [PATCH 2/5] exec: simplify the compat syscall handling Date: Sat, 27 Jun 2020 09:27:01 +0200 Message-Id: <20200627072704.2447163-3-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200627072704.2447163-1-hch@lst.de> References: <20200627072704.2447163-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, linux-parisc@vger.kernel.org, Arnd Bergmann , Brian Gerst , x86@kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Luis Chamberlain , sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The only differenence betweeen the compat exec* syscalls and their native versions is that compat_ptr sign extension, and the fact that the pointer arithmetics for the two dimensional arrays needs to use the compat pointer size. Instead of the compat wrappers and the struct user_arg_ptr machinery just use in_compat_syscall() to do the right thing for the compat case deep inside get_user_arg_ptr(). Signed-off-by: Christoph Hellwig --- arch/arm64/include/asm/unistd32.h | 4 +- arch/mips/kernel/syscalls/syscall_n32.tbl | 4 +- arch/mips/kernel/syscalls/syscall_o32.tbl | 4 +- arch/parisc/kernel/syscalls/syscall.tbl | 4 +- arch/powerpc/kernel/syscalls/syscall.tbl | 4 +- arch/s390/kernel/syscalls/syscall.tbl | 4 +- arch/sparc/kernel/syscalls.S | 4 +- arch/x86/entry/syscall_x32.c | 7 ++ arch/x86/entry/syscalls/syscall_32.tbl | 4 +- arch/x86/entry/syscalls/syscall_64.tbl | 4 +- fs/exec.c | 103 ++++-------------- include/linux/compat.h | 7 -- include/uapi/asm-generic/unistd.h | 4 +- tools/include/uapi/asm-generic/unistd.h | 4 +- .../arch/powerpc/entry/syscalls/syscall.tbl | 4 +- .../perf/arch/s390/entry/syscalls/syscall.tbl | 4 +- .../arch/x86/entry/syscalls/syscall_64.tbl | 4 +- 17 files changed, 56 insertions(+), 117 deletions(-) diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h index 6d95d0c8bf2f47..141f5d2ff1c34f 100644 --- a/arch/arm64/include/asm/unistd32.h +++ b/arch/arm64/include/asm/unistd32.h @@ -33,7 +33,7 @@ __SYSCALL(__NR_link, sys_link) #define __NR_unlink 10 __SYSCALL(__NR_unlink, sys_unlink) #define __NR_execve 11 -__SYSCALL(__NR_execve, compat_sys_execve) +__SYSCALL(__NR_execve, sys_execve) #define __NR_chdir 12 __SYSCALL(__NR_chdir, sys_chdir) /* 13 was sys_time */ @@ -785,7 +785,7 @@ __SYSCALL(__NR_memfd_create, sys_memfd_create) #define __NR_bpf 386 __SYSCALL(__NR_bpf, sys_bpf) #define __NR_execveat 387 -__SYSCALL(__NR_execveat, compat_sys_execveat) +__SYSCALL(__NR_execveat, sys_execveat) #define __NR_userfaultfd 388 __SYSCALL(__NR_userfaultfd, sys_userfaultfd) #define __NR_membarrier 389 diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl b/arch/mips/kernel/syscalls/syscall_n32.tbl index f777141f52568f..e861b5ab7179c9 100644 --- a/arch/mips/kernel/syscalls/syscall_n32.tbl +++ b/arch/mips/kernel/syscalls/syscall_n32.tbl @@ -64,7 +64,7 @@ 54 n32 getsockopt compat_sys_getsockopt 55 n32 clone __sys_clone 56 n32 fork __sys_fork -57 n32 execve compat_sys_execve +57 n32 execve sys_execve 58 n32 exit sys_exit 59 n32 wait4 compat_sys_wait4 60 n32 kill sys_kill @@ -328,7 +328,7 @@ 317 n32 getrandom sys_getrandom 318 n32 memfd_create sys_memfd_create 319 n32 bpf sys_bpf -320 n32 execveat compat_sys_execveat +320 n32 execveat sys_execveat 321 n32 userfaultfd sys_userfaultfd 322 n32 membarrier sys_membarrier 323 n32 mlock2 sys_mlock2 diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl b/arch/mips/kernel/syscalls/syscall_o32.tbl index 13280625d312e9..bba80f74e9968e 100644 --- a/arch/mips/kernel/syscalls/syscall_o32.tbl +++ b/arch/mips/kernel/syscalls/syscall_o32.tbl @@ -18,7 +18,7 @@ 8 o32 creat sys_creat 9 o32 link sys_link 10 o32 unlink sys_unlink -11 o32 execve sys_execve compat_sys_execve +11 o32 execve sys_execve 12 o32 chdir sys_chdir 13 o32 time sys_time32 14 o32 mknod sys_mknod @@ -367,7 +367,7 @@ 353 o32 getrandom sys_getrandom 354 o32 memfd_create sys_memfd_create 355 o32 bpf sys_bpf -356 o32 execveat sys_execveat compat_sys_execveat +356 o32 execveat sys_execveat 357 o32 userfaultfd sys_userfaultfd 358 o32 membarrier sys_membarrier 359 o32 mlock2 sys_mlock2 diff --git a/arch/parisc/kernel/syscalls/syscall.tbl b/arch/parisc/kernel/syscalls/syscall.tbl index 5a758fa6ec5242..23fa0d0edf3384 100644 --- a/arch/parisc/kernel/syscalls/syscall.tbl +++ b/arch/parisc/kernel/syscalls/syscall.tbl @@ -18,7 +18,7 @@ 8 common creat sys_creat 9 common link sys_link 10 common unlink sys_unlink -11 common execve sys_execve compat_sys_execve +11 common execve sys_execve 12 common chdir sys_chdir 13 32 time sys_time32 13 64 time sys_time @@ -385,7 +385,7 @@ 339 common getrandom sys_getrandom 340 common memfd_create sys_memfd_create 341 common bpf sys_bpf -342 common execveat sys_execveat compat_sys_execveat +342 common execveat sys_execveat 343 common membarrier sys_membarrier 344 common userfaultfd sys_userfaultfd 345 common mlock2 sys_mlock2 diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl index f833a319082247..c52cdab89dc0ae 100644 --- a/arch/powerpc/kernel/syscalls/syscall.tbl +++ b/arch/powerpc/kernel/syscalls/syscall.tbl @@ -20,7 +20,7 @@ 8 common creat sys_creat 9 common link sys_link 10 common unlink sys_unlink -11 nospu execve sys_execve compat_sys_execve +11 nospu execve sys_execve 12 common chdir sys_chdir 13 32 time sys_time32 13 64 time sys_time @@ -460,7 +460,7 @@ 359 common getrandom sys_getrandom 360 common memfd_create sys_memfd_create 361 common bpf sys_bpf -362 nospu execveat sys_execveat compat_sys_execveat +362 nospu execveat sys_execveat 363 32 switch_endian sys_ni_syscall 363 64 switch_endian sys_switch_endian 363 spu switch_endian sys_ni_syscall diff --git a/arch/s390/kernel/syscalls/syscall.tbl b/arch/s390/kernel/syscalls/syscall.tbl index bfdcb763395735..bd2275db2026ea 100644 --- a/arch/s390/kernel/syscalls/syscall.tbl +++ b/arch/s390/kernel/syscalls/syscall.tbl @@ -18,7 +18,7 @@ 8 common creat sys_creat sys_creat 9 common link sys_link sys_link 10 common unlink sys_unlink sys_unlink -11 common execve sys_execve compat_sys_execve +11 common execve sys_execve sys_execve 12 common chdir sys_chdir sys_chdir 13 32 time - sys_time32 14 common mknod sys_mknod sys_mknod @@ -361,7 +361,7 @@ 351 common bpf sys_bpf sys_bpf 352 common s390_pci_mmio_write sys_s390_pci_mmio_write sys_s390_pci_mmio_write 353 common s390_pci_mmio_read sys_s390_pci_mmio_read sys_s390_pci_mmio_read -354 common execveat sys_execveat compat_sys_execveat +354 common execveat sys_execveat sys_execveat 355 common userfaultfd sys_userfaultfd sys_userfaultfd 356 common membarrier sys_membarrier sys_membarrier 357 common recvmmsg sys_recvmmsg compat_sys_recvmmsg_time32 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S index db42b4fb370844..70463972152a92 100644 --- a/arch/sparc/kernel/syscalls.S +++ b/arch/sparc/kernel/syscalls.S @@ -16,12 +16,12 @@ sys64_execveat: sunos_execv: mov %g0, %o2 sys32_execve: - set compat_sys_execve, %g1 + set sys_execve, %g1 jmpl %g1, %g0 flushw sys32_execveat: - set compat_sys_execveat, %g1 + set sys_execveat, %g1 jmpl %g1, %g0 flushw #endif diff --git a/arch/x86/entry/syscall_x32.c b/arch/x86/entry/syscall_x32.c index 3d8d70d3896c87..c9f39900a93b96 100644 --- a/arch/x86/entry/syscall_x32.c +++ b/arch/x86/entry/syscall_x32.c @@ -8,6 +8,13 @@ #include #include +/* + * Reuse the 64-bit entry points for the x32 versions that occupy different + * slots in the syscall table. + */ +#define __x32_sys_execve __x64_sys_execve +#define __x32_sys_execveat __x64_sys_execveat + #define __SYSCALL_64(nr, sym) #define __SYSCALL_X32(nr, sym) extern long __x32_##sym(const struct pt_regs *); diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl index d8f8a1a69ed11f..2b1eccd3f8f697 100644 --- a/arch/x86/entry/syscalls/syscall_32.tbl +++ b/arch/x86/entry/syscalls/syscall_32.tbl @@ -22,7 +22,7 @@ 8 i386 creat sys_creat 9 i386 link sys_link 10 i386 unlink sys_unlink -11 i386 execve sys_execve compat_sys_execve +11 i386 execve sys_execve 12 i386 chdir sys_chdir 13 i386 time sys_time32 14 i386 mknod sys_mknod @@ -369,7 +369,7 @@ 355 i386 getrandom sys_getrandom 356 i386 memfd_create sys_memfd_create 357 i386 bpf sys_bpf -358 i386 execveat sys_execveat compat_sys_execveat +358 i386 execveat sys_execveat 359 i386 socket sys_socket 360 i386 socketpair sys_socketpair 361 i386 bind sys_bind diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl index 78847b32e1370f..cb3fce6ed63ebf 100644 --- a/arch/x86/entry/syscalls/syscall_64.tbl +++ b/arch/x86/entry/syscalls/syscall_64.tbl @@ -375,7 +375,7 @@ 517 x32 recvfrom compat_sys_recvfrom 518 x32 sendmsg compat_sys_sendmsg 519 x32 recvmsg compat_sys_recvmsg -520 x32 execve compat_sys_execve +520 x32 execve sys_execve 521 x32 ptrace compat_sys_ptrace 522 x32 rt_sigpending compat_sys_rt_sigpending 523 x32 rt_sigtimedwait compat_sys_rt_sigtimedwait_time64 @@ -400,6 +400,6 @@ 542 x32 getsockopt compat_sys_getsockopt 543 x32 io_setup compat_sys_io_setup 544 x32 io_submit compat_sys_io_submit -545 x32 execveat compat_sys_execveat +545 x32 execveat sys_execveat 546 x32 preadv2 compat_sys_preadv64v2 547 x32 pwritev2 compat_sys_pwritev64v2 diff --git a/fs/exec.c b/fs/exec.c index 354fdaa536ae7d..4e5db0e35797a5 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -386,47 +386,34 @@ static int bprm_mm_init(struct linux_binprm *bprm) return err; } -struct user_arg_ptr { -#ifdef CONFIG_COMPAT - bool is_compat; -#endif - union { - const char __user *const __user *native; -#ifdef CONFIG_COMPAT - const compat_uptr_t __user *compat; -#endif - } ptr; -}; - -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr) +static const char __user * +get_user_arg_ptr(const char __user *const __user *argv, int nr) { - const char __user *native; - -#ifdef CONFIG_COMPAT - if (unlikely(argv.is_compat)) { + if (in_compat_syscall()) { + const compat_uptr_t __user *compat_argv = + compat_ptr((unsigned long)argv); compat_uptr_t compat; - if (get_user(compat, argv.ptr.compat + nr)) + if (get_user(compat, compat_argv + nr)) return ERR_PTR(-EFAULT); - return compat_ptr(compat); - } -#endif - - if (get_user(native, argv.ptr.native + nr)) - return ERR_PTR(-EFAULT); + } else { + const char __user *native; - return native; + if (get_user(native, argv + nr)) + return ERR_PTR(-EFAULT); + return native; + } } /* * count() counts the number of strings in array ARGV. */ -static int count(struct user_arg_ptr argv, int max) +static int count(const char __user *const __user *argv, int max) { int i = 0; - if (argv.ptr.native != NULL) { + if (argv) { for (;;) { const char __user *p = get_user_arg_ptr(argv, i); @@ -449,7 +436,8 @@ static int count(struct user_arg_ptr argv, int max) } static int prepare_arg_pages(struct linux_binprm *bprm, - struct user_arg_ptr argv, struct user_arg_ptr envp) + const char __user *const __user *argv, + const char __user *const __user *envp) { unsigned long limit, ptr_size; @@ -497,7 +485,7 @@ static int prepare_arg_pages(struct linux_binprm *bprm, * processes's memory to the new process's stack. The call to get_user_pages() * ensures the destination page is created and not swapped out. */ -static int copy_strings(int argc, struct user_arg_ptr argv, +static int copy_strings(int argc, const char __user *const __user *argv, struct linux_binprm *bprm) { struct page *kmapped_page = NULL; @@ -1815,10 +1803,10 @@ static int exec_binprm(struct linux_binprm *bprm) return 0; } -static int __do_execveat(int fd, struct filename *filename, - struct user_arg_ptr argv, - struct user_arg_ptr envp, - int flags, struct file *file) +int do_execveat(int fd, struct filename *filename, + const char __user *const __user *argv, + const char __user *const __user *envp, + int flags, struct file *file) { char *pathbuf = NULL; struct linux_binprm *bprm; @@ -1969,17 +1957,6 @@ static int __do_execveat(int fd, struct filename *filename, return retval; } -int do_execveat(int fd, struct filename *filename, - const char __user *const __user *__argv, - const char __user *const __user *__envp, - int flags, struct file *file) -{ - struct user_arg_ptr argv = { .ptr.native = __argv }; - struct user_arg_ptr envp = { .ptr.native = __envp }; - - return __do_execveat(fd, filename, argv, envp, flags, file); -} - void set_binfmt(struct linux_binfmt *new) { struct mm_struct *mm = current->mm; @@ -2023,41 +2000,3 @@ SYSCALL_DEFINE5(execveat, return do_execveat(fd, name, argv, envp, flags, NULL); } - -#ifdef CONFIG_COMPAT -static int do_compat_execve(int fd, struct filename *filename, - const compat_uptr_t __user *__argv, - const compat_uptr_t __user *__envp, - int flags) -{ - struct user_arg_ptr argv = { - .is_compat = true, - .ptr.compat = __argv, - }; - struct user_arg_ptr envp = { - .is_compat = true, - .ptr.compat = __envp, - }; - - return __do_execveat(fd, filename, argv, envp, flags, NULL); -} - -COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename, - const compat_uptr_t __user *, argv, - const compat_uptr_t __user *, envp) -{ - return do_compat_execve(AT_FDCWD, getname(filename), argv, envp, 0); -} - -COMPAT_SYSCALL_DEFINE5(execveat, int, fd, - const char __user *, filename, - const compat_uptr_t __user *, argv, - const compat_uptr_t __user *, envp, - int, flags) -{ - int lookup_flags = (flags & AT_EMPTY_PATH) ? LOOKUP_EMPTY : 0; - struct filename *name = getname_flags(filename, lookup_flags, NULL); - - return do_compat_execve(fd, name, argv, envp, flags); -} -#endif diff --git a/include/linux/compat.h b/include/linux/compat.h index e90100c0de72e4..5e8f6a588e0d43 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -752,10 +752,6 @@ asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, asmlinkage long compat_sys_keyctl(u32 option, u32 arg2, u32 arg3, u32 arg4, u32 arg5); -/* arch/example/kernel/sys_example.c */ -asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv, - const compat_uptr_t __user *envp); - /* mm/fadvise.c: No generic prototype for fadvise64_64 */ /* mm/, CONFIG_MMU only */ @@ -806,9 +802,6 @@ asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid, const struct compat_iovec __user *lvec, compat_ulong_t liovcnt, const struct compat_iovec __user *rvec, compat_ulong_t riovcnt, compat_ulong_t flags); -asmlinkage long compat_sys_execveat(int dfd, const char __user *filename, - const compat_uptr_t __user *argv, - const compat_uptr_t __user *envp, int flags); asmlinkage ssize_t compat_sys_preadv2(compat_ulong_t fd, const struct compat_iovec __user *vec, compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags); diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h index f4a01305d9a65c..c639d04a094b8b 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h @@ -640,7 +640,7 @@ __SC_COMP(__NR_keyctl, sys_keyctl, compat_sys_keyctl) #define __NR_clone 220 __SYSCALL(__NR_clone, sys_clone) #define __NR_execve 221 -__SC_COMP(__NR_execve, sys_execve, compat_sys_execve) +__SYSCALL(__NR_execve, sys_execve) #define __NR3264_mmap 222 __SC_3264(__NR3264_mmap, sys_mmap2, sys_mmap) @@ -751,7 +751,7 @@ __SYSCALL(__NR_memfd_create, sys_memfd_create) #define __NR_bpf 280 __SYSCALL(__NR_bpf, sys_bpf) #define __NR_execveat 281 -__SC_COMP(__NR_execveat, sys_execveat, compat_sys_execveat) +__SYSCALL(__NR_execveat, sys_execveat) #define __NR_userfaultfd 282 __SYSCALL(__NR_userfaultfd, sys_userfaultfd) #define __NR_membarrier 283 diff --git a/tools/include/uapi/asm-generic/unistd.h b/tools/include/uapi/asm-generic/unistd.h index f4a01305d9a65c..c639d04a094b8b 100644 --- a/tools/include/uapi/asm-generic/unistd.h +++ b/tools/include/uapi/asm-generic/unistd.h @@ -640,7 +640,7 @@ __SC_COMP(__NR_keyctl, sys_keyctl, compat_sys_keyctl) #define __NR_clone 220 __SYSCALL(__NR_clone, sys_clone) #define __NR_execve 221 -__SC_COMP(__NR_execve, sys_execve, compat_sys_execve) +__SYSCALL(__NR_execve, sys_execve) #define __NR3264_mmap 222 __SC_3264(__NR3264_mmap, sys_mmap2, sys_mmap) @@ -751,7 +751,7 @@ __SYSCALL(__NR_memfd_create, sys_memfd_create) #define __NR_bpf 280 __SYSCALL(__NR_bpf, sys_bpf) #define __NR_execveat 281 -__SC_COMP(__NR_execveat, sys_execveat, compat_sys_execveat) +__SYSCALL(__NR_execveat, sys_execveat) #define __NR_userfaultfd 282 __SYSCALL(__NR_userfaultfd, sys_userfaultfd) #define __NR_membarrier 283 diff --git a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl index 35b61bfc1b1ae9..42bf8b461a0ed6 100644 --- a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +++ b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl @@ -18,7 +18,7 @@ 8 common creat sys_creat 9 common link sys_link 10 common unlink sys_unlink -11 nospu execve sys_execve compat_sys_execve +11 nospu execve sys_execve sys_execve 12 common chdir sys_chdir 13 32 time sys_time32 13 64 time sys_time @@ -454,7 +454,7 @@ 359 common getrandom sys_getrandom 360 common memfd_create sys_memfd_create 361 common bpf sys_bpf -362 nospu execveat sys_execveat compat_sys_execveat +362 nospu execveat sys_execveat sys_execveat 363 32 switch_endian sys_ni_syscall 363 64 switch_endian ppc_switch_endian 363 spu switch_endian sys_ni_syscall diff --git a/tools/perf/arch/s390/entry/syscalls/syscall.tbl b/tools/perf/arch/s390/entry/syscalls/syscall.tbl index b38d48464368dc..f3c16f2d9746ac 100644 --- a/tools/perf/arch/s390/entry/syscalls/syscall.tbl +++ b/tools/perf/arch/s390/entry/syscalls/syscall.tbl @@ -18,7 +18,7 @@ 8 common creat sys_creat compat_sys_creat 9 common link sys_link compat_sys_link 10 common unlink sys_unlink compat_sys_unlink -11 common execve sys_execve compat_sys_execve +11 common execve sys_execve sys_execve 12 common chdir sys_chdir compat_sys_chdir 13 32 time - compat_sys_time 14 common mknod sys_mknod compat_sys_mknod @@ -361,7 +361,7 @@ 351 common bpf sys_bpf compat_sys_bpf 352 common s390_pci_mmio_write sys_s390_pci_mmio_write compat_sys_s390_pci_mmio_write 353 common s390_pci_mmio_read sys_s390_pci_mmio_read compat_sys_s390_pci_mmio_read -354 common execveat sys_execveat compat_sys_execveat +354 common execveat sys_execveat sys_execveat 355 common userfaultfd sys_userfaultfd sys_userfaultfd 356 common membarrier sys_membarrier sys_membarrier 357 common recvmmsg sys_recvmmsg compat_sys_recvmmsg diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl index 78847b32e1370f..cb3fce6ed63ebf 100644 --- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl +++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl @@ -375,7 +375,7 @@ 517 x32 recvfrom compat_sys_recvfrom 518 x32 sendmsg compat_sys_sendmsg 519 x32 recvmsg compat_sys_recvmsg -520 x32 execve compat_sys_execve +520 x32 execve sys_execve 521 x32 ptrace compat_sys_ptrace 522 x32 rt_sigpending compat_sys_rt_sigpending 523 x32 rt_sigtimedwait compat_sys_rt_sigtimedwait_time64 @@ -400,6 +400,6 @@ 542 x32 getsockopt compat_sys_getsockopt 543 x32 io_setup compat_sys_io_setup 544 x32 io_submit compat_sys_io_submit -545 x32 execveat compat_sys_execveat +545 x32 execveat sys_execveat 546 x32 preadv2 compat_sys_preadv64v2 547 x32 pwritev2 compat_sys_pwritev64v2 From patchwork Sat Jun 27 07:27:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11629291 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 84A2B90 for ; Sat, 27 Jun 2020 07:29:35 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E19C2081A for ; Sat, 27 Jun 2020 07:29:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Z38sOL1p"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Hmv49r3C" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E19C2081A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Zib1PnPStHBahE8NRb7E8QgnHvp416ZZQzYPGaHhnyk=; b=Z38sOL1ptoLq0ROebQuGKmK0J y9ygRgf5nrPmhMrQ9QcfDKL1eNiHroFuNjPU4qg9MsqiPSTpWwsMHyHukERr1p9dDywsJR52GoiYI dwzbH2xDfKn2vueCYdNvg2bHRwAJimGotDqv7SWQN+Vh9VJR82b+J2RZToaCKkriX113OYCi4mjs6 k9xwKEewf+H2f0aAhyB7iNI4R83J53K4kXtpskf1ktyvyGqZXTx4X+JPoMaeP4JtWJgYJWqGhedrv 4m4iz7Ur2VTYOWHB0WqWD/2g0RiJi1M/W15fVBoOS5iG3KNWrl8tfEmkrfFHTBOUkAwZNfRgbyN53 JvTs7MxBg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5FN-0000ga-1N; Sat, 27 Jun 2020 07:27:34 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5FG-0000fW-6L for linux-arm-kernel@merlin.infradead.org; Sat, 27 Jun 2020 07:27:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=e+EEFqv4wjvmMJMr72kiOJnRNTJBptkSbMiAtyzJmZo=; b=Hmv49r3CEmsDSDP480cNnzfK7w M3s1BcGA2mZQSaWszed4Or9AOiEvLo8iLCVA3H3ujoq11ZE2F99oFhzdrm//HZOUjmgSMMBeGtDL1 7s4Kzo7/uoC3XaP+SzZEOcJKGplMLmqVKpk4aca1P7/gqFa+WORKj4gGb/NPXrZq+xS9QnikFae3r mQO19SpH9RxLFYE9PXwB3oebJuuv96VGrSxqqxREQDu/tieO9Xbo2JhxReFnbbjdoAK9oKyYnaalL SS6ASKKcYEsdBf+vdTxbvasr8eRWFmEeqzzVzuSsv/Eset4BUpWV5lzPXVIwRvWHCPpQ1vnzNIiTq dcPumu1w==; Received: from [2001:4bb8:184:76e3:595:ba65:ae56:65a6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5FD-0006X9-8n; Sat, 27 Jun 2020 07:27:24 +0000 From: Christoph Hellwig To: Al Viro Subject: [PATCH 3/5] exec: cleanup the count() function Date: Sat, 27 Jun 2020 09:27:02 +0200 Message-Id: <20200627072704.2447163-4-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200627072704.2447163-1-hch@lst.de> References: <20200627072704.2447163-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, linux-parisc@vger.kernel.org, Arnd Bergmann , Brian Gerst , x86@kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Luis Chamberlain , sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Remove the max argument as it is hard wired to MAX_ARG_STRINGS, and give the function a slightly less generic name. Signed-off-by: Christoph Hellwig --- fs/exec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 4e5db0e35797a5..a5d91f8b1341d5 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -407,9 +407,9 @@ get_user_arg_ptr(const char __user *const __user *argv, int nr) } /* - * count() counts the number of strings in array ARGV. + * count_strings() counts the number of strings in array ARGV. */ -static int count(const char __user *const __user *argv, int max) +static int count_strings(const char __user *const __user *argv) { int i = 0; @@ -423,7 +423,7 @@ static int count(const char __user *const __user *argv, int max) if (IS_ERR(p)) return -EFAULT; - if (i >= max) + if (i >= MAX_ARG_STRINGS) return -E2BIG; ++i; @@ -441,11 +441,11 @@ static int prepare_arg_pages(struct linux_binprm *bprm, { unsigned long limit, ptr_size; - bprm->argc = count(argv, MAX_ARG_STRINGS); + bprm->argc = count_strings(argv); if (bprm->argc < 0) return bprm->argc; - bprm->envc = count(envp, MAX_ARG_STRINGS); + bprm->envc = count_strings(envp); if (bprm->envc < 0) return bprm->envc; From patchwork Sat Jun 27 07:27:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11629295 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1365090 for ; Sat, 27 Jun 2020 07:29:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E17642088E for ; Sat, 27 Jun 2020 07:29:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hna035bt"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="XI6CndVI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E17642088E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qZ5wbg9Npq1Fij6bnxSNug/Y67Mf+8g5hXXg5i1VUxM=; b=hna035btt8gEEWlTS68oWHSio Fy5xAS2HvN1pA6rtnwAUCwj7nkyuYjKMzNbdZMteUJiKpx3NX4HJ+Ks2Y8qXZgiGcZqsVtT0OVPQp f8ANgXOiNOdzaKucYTQGl6kn1yEEPUQZq3UnN8H4gnUinPLYvKBXw2visMok6SG54rnSjZly1r4Fl q5CUfpmMcKANJ3ySqBHPRtugwUaEeK8sPjPGJ4KhtaH76BpOsa2q8baTHWYULgirMxbqE4jyj+75q FktgCoD8G9rJa4ACBF2UFQp43Fv7zaCZGfLiM2gstZpYMCN4aSBDMiXS4T8UUMf1GweCPSrDr8RqW hAmeT12tg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5FU-0000jh-QT; Sat, 27 Jun 2020 07:27:40 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5FI-0000gH-LG for linux-arm-kernel@merlin.infradead.org; Sat, 27 Jun 2020 07:27:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=6JtQFSFZNuHNYVW/hbRiOl0cmjzNgKOe7nvuIEAqZOM=; b=XI6CndVIJXMc32UDFraE+/6BDg kgds46nEXHDzwZqAki7Xb/CkKeJmq+gVJ2JvzJ+lQCBP0sos5RAoQ3vxfhbkC+HV9yZJWF5cYmSlt yJzPIZc1/FtkoJpBFgLIg6cR0UZEiIYy/d3lp4NDmonFbNY45srXYi70rr1817pjw+ECoDyEWFE4i RWKBBRkhhsWXJwaX4Gee6Ibaxv79W68lBh2leHgVD/F2uOHmizhBuO1H84Aq4FfnyBZUyjmrpaLul AfaqHFl5sBzlXCSXZ33BEukRpaDWm9lpNdx9d5FLRiYJSgKkNbGtmyNGWh24+udriGn3MVst9oeaO S4UZ/j6g==; Received: from [2001:4bb8:184:76e3:595:ba65:ae56:65a6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5FG-0006XG-3J; Sat, 27 Jun 2020 07:27:27 +0000 From: Christoph Hellwig To: Al Viro Subject: [PATCH 4/5] exec: split prepare_arg_pages Date: Sat, 27 Jun 2020 09:27:03 +0200 Message-Id: <20200627072704.2447163-5-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200627072704.2447163-1-hch@lst.de> References: <20200627072704.2447163-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, linux-parisc@vger.kernel.org, Arnd Bergmann , Brian Gerst , x86@kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Luis Chamberlain , sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Move counting the arguments and enviroment variables out of prepare_arg_pages and rename the rest of the function to check_arg_limit. This prepares for a version of do_execvat that takes kernel pointers. Signed-off-by: Christoph Hellwig --- fs/exec.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index a5d91f8b1341d5..34781db6bf6889 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -435,20 +435,10 @@ static int count_strings(const char __user *const __user *argv) return i; } -static int prepare_arg_pages(struct linux_binprm *bprm, - const char __user *const __user *argv, - const char __user *const __user *envp) +static int check_arg_limit(struct linux_binprm *bprm) { unsigned long limit, ptr_size; - bprm->argc = count_strings(argv); - if (bprm->argc < 0) - return bprm->argc; - - bprm->envc = count_strings(envp); - if (bprm->envc < 0) - return bprm->envc; - /* * Limit to 1/4 of the max stack size or 3/4 of _STK_LIM * (whichever is smaller) for the argv+env strings. @@ -1886,7 +1876,19 @@ int do_execveat(int fd, struct filename *filename, if (retval) goto out_unmark; - retval = prepare_arg_pages(bprm, argv, envp); + bprm->argc = count_strings(argv); + if (bprm->argc < 0) { + retval = bprm->argc; + goto out; + } + + bprm->envc = count_strings(envp); + if (bprm->envc < 0) { + retval = bprm->envc; + goto out; + } + + retval = check_arg_limit(bprm); if (retval < 0) goto out; From patchwork Sat Jun 27 07:27:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11629293 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF30F90 for ; Sat, 27 Jun 2020 07:29:39 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B81672088E for ; Sat, 27 Jun 2020 07:29:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZCpmKIGr"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="TlPnTimq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B81672088E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=axEe4vBNHcU+nhTcNKWdJqAWSElGIG2+mmjhR3nHspE=; b=ZCpmKIGr7sXkslhXMB5cleCIt 31i9OSVcQad4S3c11FyxephQmLFuGSD2RXq4LtnvwwifL+3vjkL3A4Jsv/IXKMvphksui9dYibh2V McF0HWbHs9jskhfCuU9P21VixiTFdhlgnjB8cBOljuTGut/e0kl9Mz9IrIDFHdCNBYPDVYlB993JM sg2FBGZRljej6RqwtXfGkPOHpgCiCK1MSHQVRCDzwj72GajxCALUQEAFEHiwCioa+SAjZdGiNtMVH iEZ/CwFL+067kBI6feaiBfEYY1XMUj0KI8MfHMz2aTeM0dt5xa09qCgHXmPTy5pZEMELnKQmIBXoC 2rWX+oBPQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5FY-0000ko-Rw; Sat, 27 Jun 2020 07:27:44 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5FL-0000h6-SZ for linux-arm-kernel@merlin.infradead.org; Sat, 27 Jun 2020 07:27:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=mURemflipje9eYopYQ4h3uusWn3YXYVAu+uuVrAN7pQ=; b=TlPnTimqsO2m30LvldYZKWVizZ hpNyMesz2KmBGpNgKstCa9x+hZjeq/G/LSRMkegjvZ22YoGmrkgnX+pZNWw5KGTu0v468zw9T4sZI Xu/MpJ2eSYmAE+ipVFlRyXHmj7yINmDtCVRDeT4inn/UpLST2JkhmV8QUh9BXIQDcWZI6goY8hoTK 4LzatZU6wTyWdTn1fSGkRe6TQ02ZarzjB0rP81o5Zm/pl6DVfHmLMMgslXwjVzsTycl+tfWpI1waO hEgw54/dYKj+ZkSuM7HhgjVT0BbFo583J9Wu65cTYBtF8e6ZyiugH7Oj2JWPx8rHz3ol1injsjGRn /VsHUW/A==; Received: from [2001:4bb8:184:76e3:595:ba65:ae56:65a6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5FI-0006XS-Jx; Sat, 27 Jun 2020 07:27:30 +0000 From: Christoph Hellwig To: Al Viro Subject: [PATCH 5/5] exec: add a kernel_execveat helper Date: Sat, 27 Jun 2020 09:27:04 +0200 Message-Id: <20200627072704.2447163-6-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200627072704.2447163-1-hch@lst.de> References: <20200627072704.2447163-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, linux-parisc@vger.kernel.org, Arnd Bergmann , Brian Gerst , x86@kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Luis Chamberlain , sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add a kernel_execveat helper to execute a binary with kernel space argv and envp pointers. Switch executing init and user mode helpers to this new helper instead of relying on the implicit set_fs(KERNEL_DS) for early init code and kernel threads, and move the getname call into the do_execve helper. Signed-off-by: Christoph Hellwig --- fs/exec.c | 109 ++++++++++++++++++++++++++++++++-------- include/linux/binfmts.h | 6 +-- init/main.c | 6 +-- kernel/umh.c | 8 ++- 4 files changed, 95 insertions(+), 34 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 34781db6bf6889..7923b8334ae600 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -435,6 +435,21 @@ static int count_strings(const char __user *const __user *argv) return i; } +static int count_kernel_strings(const char *const *argv) +{ + int i; + + if (!argv) + return 0; + + for (i = 0; argv[i]; i++) { + if (i >= MAX_ARG_STRINGS) + return -E2BIG; + } + + return i; +} + static int check_arg_limit(struct linux_binprm *bprm) { unsigned long limit, ptr_size; @@ -611,6 +626,19 @@ int copy_string_kernel(const char *arg, struct linux_binprm *bprm) } EXPORT_SYMBOL(copy_string_kernel); +static int copy_strings_kernel(int argc, const char *const *argv, + struct linux_binprm *bprm) +{ + int ret; + + while (argc-- > 0) { + ret = copy_string_kernel(argv[argc], bprm); + if (ret) + break; + } + return ret; +} + #ifdef CONFIG_MMU /* @@ -1793,9 +1821,11 @@ static int exec_binprm(struct linux_binprm *bprm) return 0; } -int do_execveat(int fd, struct filename *filename, +static int __do_execveat(int fd, struct filename *filename, const char __user *const __user *argv, const char __user *const __user *envp, + const char *const *kernel_argv, + const char *const *kernel_envp, int flags, struct file *file) { char *pathbuf = NULL; @@ -1876,16 +1906,30 @@ int do_execveat(int fd, struct filename *filename, if (retval) goto out_unmark; - bprm->argc = count_strings(argv); - if (bprm->argc < 0) { - retval = bprm->argc; - goto out; - } + if (unlikely(kernel_argv)) { + bprm->argc = count_kernel_strings(kernel_argv); + if (bprm->argc < 0) { + retval = bprm->argc; + goto out; + } - bprm->envc = count_strings(envp); - if (bprm->envc < 0) { - retval = bprm->envc; - goto out; + bprm->envc = count_kernel_strings(kernel_envp); + if (bprm->envc < 0) { + retval = bprm->envc; + goto out; + } + } else { + bprm->argc = count_strings(argv); + if (bprm->argc < 0) { + retval = bprm->argc; + goto out; + } + + bprm->envc = count_strings(envp); + if (bprm->envc < 0) { + retval = bprm->envc; + goto out; + } } retval = check_arg_limit(bprm); @@ -1902,13 +1946,22 @@ int do_execveat(int fd, struct filename *filename, goto out; bprm->exec = bprm->p; - retval = copy_strings(bprm->envc, envp, bprm); - if (retval < 0) - goto out; - retval = copy_strings(bprm->argc, argv, bprm); - if (retval < 0) - goto out; + if (unlikely(kernel_argv)) { + retval = copy_strings_kernel(bprm->envc, kernel_envp, bprm); + if (retval < 0) + goto out; + retval = copy_strings_kernel(bprm->argc, kernel_argv, bprm); + if (retval < 0) + goto out; + } else { + retval = copy_strings(bprm->envc, envp, bprm); + if (retval < 0) + goto out; + retval = copy_strings(bprm->argc, argv, bprm); + if (retval < 0) + goto out; + } retval = exec_binprm(bprm); if (retval < 0) @@ -1959,6 +2012,23 @@ int do_execveat(int fd, struct filename *filename, return retval; } +static int do_execveat(int fd, const char *filename, + const char __user *const __user *argv, + const char __user *const __user *envp, int flags) +{ + int lookup_flags = (flags & AT_EMPTY_PATH) ? LOOKUP_EMPTY : 0; + struct filename *name = getname_flags(filename, lookup_flags, NULL); + + return __do_execveat(fd, name, argv, envp, NULL, NULL, flags, NULL); +} + +int kernel_execveat(int fd, const char *filename, const char *const *argv, + const char *const *envp, int flags, struct file *file) +{ + return __do_execveat(fd, getname_kernel(filename), NULL, NULL, argv, + envp, flags, file); +} + void set_binfmt(struct linux_binfmt *new) { struct mm_struct *mm = current->mm; @@ -1988,7 +2058,7 @@ SYSCALL_DEFINE3(execve, const char __user *const __user *, argv, const char __user *const __user *, envp) { - return do_execveat(AT_FDCWD, getname(filename), argv, envp, 0, NULL); + return do_execveat(AT_FDCWD, filename, argv, envp, 0); } SYSCALL_DEFINE5(execveat, @@ -1997,8 +2067,5 @@ SYSCALL_DEFINE5(execveat, const char __user *const __user *, envp, int, flags) { - int lookup_flags = (flags & AT_EMPTY_PATH) ? LOOKUP_EMPTY : 0; - struct filename *name = getname_flags(filename, lookup_flags, NULL); - - return do_execveat(fd, name, argv, envp, flags, NULL); + return do_execveat(fd, filename, argv, envp, flags); } diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index bed702e4b1fbd9..1e61c980c16354 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h @@ -134,9 +134,7 @@ int copy_string_kernel(const char *arg, struct linux_binprm *bprm); extern void set_binfmt(struct linux_binfmt *new); extern ssize_t read_code(struct file *, unsigned long, loff_t, size_t); -int do_execveat(int fd, struct filename *filename, - const char __user *const __user *__argv, - const char __user *const __user *__envp, - int flags, struct file *file); +int kernel_execveat(int fd, const char *filename, const char *const *argv, + const char *const *envp, int flags, struct file *file); #endif /* _LINUX_BINFMTS_H */ diff --git a/init/main.c b/init/main.c index 838950ea7bca22..33de235dc2aa00 100644 --- a/init/main.c +++ b/init/main.c @@ -1329,10 +1329,8 @@ static int run_init_process(const char *init_filename) pr_debug(" with environment:\n"); for (p = envp_init; *p; p++) pr_debug(" %s\n", *p); - return do_execveat(AT_FDCWD, getname_kernel(init_filename), - (const char __user *const __user *)argv_init, - (const char __user *const __user *)envp_init, - 0, NULL); + return kernel_execveat(AT_FDCWD, init_filename, argv_init, envp_init, 0, + NULL); } static int try_to_run_init_process(const char *init_filename) diff --git a/kernel/umh.c b/kernel/umh.c index 7aa9a5817582ca..1284823dbad338 100644 --- a/kernel/umh.c +++ b/kernel/umh.c @@ -103,11 +103,9 @@ static int call_usermodehelper_exec_async(void *data) commit_creds(new); sub_info->pid = task_pid_nr(current); - retval = do_execveat(AT_FDCWD, - sub_info->path ? getname_kernel(sub_info->path) : NULL, - (const char __user *const __user *)sub_info->argv, - (const char __user *const __user *)sub_info->envp, - 0, sub_info->file); + retval = kernel_execveat(AT_FDCWD, sub_info->path, + (const char *const *)sub_info->argv, + (const char *const *)sub_info->envp, 0, sub_info->file); if (sub_info->file && !retval) current->flags |= PF_UMH; out: