From nobody Fri Jun 17 19:41:00 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 88CE185D5F0; Fri, 17 Jun 2022 19:41:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LPqCf0BVnz3hkF; Fri, 17 Jun 2022 19:41:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=k0HevBk2hv702F/lWPdLblKDHFvnVh38w6CgKcqlGfc=; b=nGLXfOzy5t26hjIfSmHSx164/vKcwnMUZOTRdBTGBf8MPGNWmyqbFeLLMhbLB268ONe8E4 Nwb+ofwHkIooQwvV/cFUmEcDdYVx7VEPlVn7W7DtSPYQcMjs+gGLtXC5mt8hqzMXls9swk AfJpQTRhKyLM+LWZuJejdL4yZJkCAeHJWucibEo32pk+bGpLtu5mHmw6v1CAazmXf22Ti/ UrRFFUWDuhL8VjLOQK1NkuSPdzJ2ZtixLbC0djMlf370WC+QTzghvBMVFxl6CuM76OeldH 2saNA9YWhple5O8siyFDxA8SfxncGeQjblNdSR43fJfrreRymgUE4gX1eF3FMQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D9859257F4; Fri, 17 Jun 2022 19:41:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25HJf06T029906; Fri, 17 Jun 2022 19:41:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJf02G029905; Fri, 17 Jun 2022 19:41:00 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:41:00 GMT Message-Id: <202206171941.25HJf02G029905@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: 959d0bdc24de - stable/13 - linux(4): Deduplicate execve List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 959d0bdc24def638d7a09ff8eea44512cba1b4fd Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=k0HevBk2hv702F/lWPdLblKDHFvnVh38w6CgKcqlGfc=; b=p4a9nZH6pBavP+TLc+NsQbfH4Vubh9KRmCHvINtEqdF5X72WLEeBz5knqfLMV7wovGy9NA WGVPoHn3Pe7E1WxUlWkr3w6gOYdU7koSVR1MfG/uknZBSgWTuanEwBcBg6w/m8xjZR5qjd y3uGui8lfuOfPoM6Ke3xuaF7885bGUGXAM7a1ZwuD68u05Vf65lUVM96BKN6w0eFpJgkXP 2EFfrVcXG0tzuscvhHr2FM7kx4hoQpVJKL/QJ1KGRIpANrAVE8joyqzB50g9EXhbuX2mfJ BXGRoSCtRqXpeH8mA5HN8TzvRKnMsR7Aoeq1Yy5vnLUCWv3W/2dTuG1nCdGdXw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494862; a=rsa-sha256; cv=none; b=ML6F8O24QnPQ4SfFveooLFrTxN3qtF4ebWYjgAtk/K3+RlYvlisoZw18A4CdFI4Jbr2HkZ VC0Kv5kr5qOC/r92tYPB/uUNjUJ3+ssbJ/NCVk2T1B48eLNtod1TRfg+qilTKGvSNWlZXU bkrrVSose9p+zz+4X4E9ZLQKO7yrHurzyC7d7F+I8jyz1HyNfNEbeWwWJ+LypzgOT4EnGN uPSMEz7eMkyk1rV3VzsMmmHNZ1qMcfj6aP3s9IvI2RSCm2kIPZ9AlRAnkMynUhprx2Epfz hT6RVj1COUkVDtGLWOxQl8pkif35wHvq76eCvKuV/SVx3Np6EdyX0gx/EsuRnA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=959d0bdc24def638d7a09ff8eea44512cba1b4fd commit 959d0bdc24def638d7a09ff8eea44512cba1b4fd Author: Dmitry Chagin AuthorDate: 2022-06-17 19:35:30 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:35:30 +0000 linux(4): Deduplicate execve As linux_execve is common across archs, except amd64 32-bit Linuxulator, move it under compat/linux. Noted by: andrew@ MFC after: 2 weeks (cherry picked from commit 26700ac0c4d0466c00f944bde9613d18625d1f91) --- sys/amd64/linux/linux_machdep.c | 27 --------------------------- sys/arm64/linux/linux_machdep.c | 32 -------------------------------- sys/compat/linux/linux_misc.c | 28 ++++++++++++++++++++++++++++ sys/i386/linux/linux_machdep.c | 25 ------------------------- 4 files changed, 28 insertions(+), 84 deletions(-) diff --git a/sys/amd64/linux/linux_machdep.c b/sys/amd64/linux/linux_machdep.c index 18be62dab9ae..1c042424f3ea 100644 --- a/sys/amd64/linux/linux_machdep.c +++ b/sys/amd64/linux/linux_machdep.c @@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -83,8 +82,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include - #include #include #include @@ -98,30 +95,6 @@ __FBSDID("$FreeBSD$"); #define LINUX_ARCH_AMD64 0xc000003e -int -linux_execve(struct thread *td, struct linux_execve_args *args) -{ - struct image_args eargs; - char *path; - int error; - - LINUX_CTR(execve); - - if (!LUSECONVPATH(td)) { - error = exec_copyin_args(&eargs, args->path, UIO_USERSPACE, - args->argp, args->envp); - } else { - LCONVPATHEXIST(args->path, &path); - error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, args->argp, - args->envp); - LFREEPATH(path); - } - if (error == 0) - error = linux_common_execve(td, &eargs); - AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); - return (error); -} - int linux_set_upcall(struct thread *td, register_t stack) { diff --git a/sys/arm64/linux/linux_machdep.c b/sys/arm64/linux/linux_machdep.c index 420f50cb3055..0bfe51f7da1e 100644 --- a/sys/arm64/linux/linux_machdep.c +++ b/sys/arm64/linux/linux_machdep.c @@ -33,21 +33,15 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include #include #include -#include - -#include - #include #include #include -#include #include #include #include @@ -61,32 +55,6 @@ LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE); /* DTrace probes */ LIN_SDT_PROBE_DEFINE0(machdep, linux_mmap2, todo); -/* - * LINUXTODO: deduplicate; linux_execve is common across archs, except that on - * amd64 compat linuxulator it calls freebsd32_exec_copyin_args. - */ -int -linux_execve(struct thread *td, struct linux_execve_args *uap) -{ - struct image_args eargs; - char *path; - int error; - - if (!LUSECONVPATH(td)) { - error = exec_copyin_args(&eargs, uap->path, UIO_USERSPACE, - uap->argp, uap->envp); - } else { - LCONVPATHEXIST(uap->path, &path); - error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, - uap->argp, uap->envp); - LFREEPATH(path); - } - if (error == 0) - error = linux_common_execve(td, &eargs); - AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); - return (error); -} - int linux_set_upcall(struct thread *td, register_t stack) { diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 55a16d13e400..bffef4c838dd 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #endif #include +#include #include #include #include @@ -74,6 +75,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -2906,3 +2908,29 @@ linux_seccomp(struct thread *td, struct linux_seccomp_args *args) return (EINVAL); } } + +#ifndef COMPAT_LINUX32 +int +linux_execve(struct thread *td, struct linux_execve_args *args) +{ + struct image_args eargs; + char *path; + int error; + + LINUX_CTR(execve); + + if (!LUSECONVPATH(td)) { + error = exec_copyin_args(&eargs, args->path, UIO_USERSPACE, + args->argp, args->envp); + } else { + LCONVPATHEXIST(args->path, &path); + error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, args->argp, + args->envp); + LFREEPATH(path); + } + if (error == 0) + error = linux_common_execve(td, &eargs); + AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); + return (error); +} +#endif diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c index 1e665eb9f505..dc156dbd673d 100644 --- a/sys/i386/linux/linux_machdep.c +++ b/sys/i386/linux/linux_machdep.c @@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -61,8 +60,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include - #include #include #include @@ -97,28 +94,6 @@ struct l_old_select_argv { struct l_timeval *timeout; }; -int -linux_execve(struct thread *td, struct linux_execve_args *args) -{ - struct image_args eargs; - char *newpath; - int error; - - if (!LUSECONVPATH(td)) { - error = exec_copyin_args(&eargs, args->path, UIO_USERSPACE, - args->argp, args->envp); - } else { - LCONVPATHEXIST(args->path, &newpath); - error = exec_copyin_args(&eargs, newpath, UIO_SYSSPACE, - args->argp, args->envp); - LFREEPATH(newpath); - } - if (error == 0) - error = linux_common_execve(td, &eargs); - AUDIT_SYSCALL_EXIT(error == EJUSTRETURN ? 0 : error, td); - return (error); -} - struct l_ipc_kludge { struct l_msgbuf *msgp; l_long msgtyp;