From nobody Fri Jun 17 19:36:52 2022 X-Original-To: dev-commits-src-all@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 27DB785A35D; Fri, 17 Jun 2022 19:36:54 +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 4LPq6r6zK4z3P6G; Fri, 17 Jun 2022 19:36:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494613; 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=qv4LamoaSxEjIHPbk9neqrZiIWKGHuiWyXtElj7aFmE=; b=SS2ZLiTqGhJLMc5wsSJvrgfwgQ1CJdiaOPBNzQcxwir3hfi/0SjM8Hp+rt/E0uIcJkiD90 PJ8WGK+hCRwOdkQq3XDdjMmOS9kCaKMd1qXbi3ZLFF51oRAfHUER115U0ZBVV5gp2NPgXL UQBP/kUxW3KC/DfVKf5oI9F7rWrUIeGnc56GT3BD4p4eDygsGuH5d1cS/+Nx0py7FKdZ1N 8q0kqvJUMEmy6UepluI0AaRs+caDXZW+JUhiMD82k+C8+kA1NbaWxT7dHKQZ+Ex+Sv1TCQ 8JNj3ieQAbqHI+jSYgngF5bxZtUuvonjn7LKqG9Y2eqXwsU7/prE61RXo4vyvQ== 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 8CDA425C33; Fri, 17 Jun 2022 19:36:52 +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 25HJaqsv012607; Fri, 17 Jun 2022 19:36:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJaqvD012606; Fri, 17 Jun 2022 19:36:52 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:36:52 GMT Message-Id: <202206171936.25HJaqvD012606@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: 54689a282aee - stable/13 - linux(4): Modify sv_onexec hook to return an error. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: 54689a282aee8075063228881ee577de181967b6 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494613; 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=qv4LamoaSxEjIHPbk9neqrZiIWKGHuiWyXtElj7aFmE=; b=WX3YtFqL/zATuL7XmGm2wQi9ZVARTeSXDjXw0gVnDjFVD7nQhMMavxTEf0fyarnaGMmPlk EcxN7EwFtgqgfwu45LtMadZ0zaFEKfN0kkLT8gSMsIz1+kOhT0Ul/DHEgjhoci92VprRx5 aQ1JcNwuECGrgDnPVlGzho/okWcsfTRT+Hlsy/bNjfymmdliqYV0aF1DHSP9EuUXTeO0x5 fyDoo5B5lDEEj7RglYbczrXlgqqlS7SOlXEE9SacUO0UQqeFZtHnVRyisHL0ODYrTPaoiM mn8lJGHGm16LuOgNyuhgwmyHhnSxWes9Jop+Dq+uZzq7R8xnWZMNSj2Hguz4YQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494613; a=rsa-sha256; cv=none; b=sjxgL+C2jBxodAwil9k9/7Sl/kcEAuD+j5yezO56KUQB3NAlz296+Q0v/4LNPPEcfsORjC 3dXRlzG2Q5GTxqkA3h/WTYEjaOjrdiotkodJcgqomQMxtMdbtjPwzTB7SNhwvKLmC+5e/0 +tw3V6xqMLmf99+Y88YXHZr6GMzR4ThfQqbvWYdf+rRq7NTVIU+86kFkB/LSC3mU6TbiFO iaoHCAHY5mCIlM/dg0wNTLyb2Gkev5hCNWzyfcmSyQFmJLeD3m0zw9FB7O6X24S0oXtvKA d83bzh4zwfEZ2mBCO0IV1hGZLLXp3pFPLm3X71IMzB2eMOEk4iX8i/dY9mENmw== 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=54689a282aee8075063228881ee577de181967b6 commit 54689a282aee8075063228881ee577de181967b6 Author: Dmitry Chagin AuthorDate: 2022-06-17 19:33:05 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:33:05 +0000 linux(4): Modify sv_onexec hook to return an error. Temporary add stubs to the Linux emulation layer which calls the existing hook. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D30911 MFC after: 2 weeks (cherry picked from commit 5fd9cd53d256e08c601548c425bfcb3472f2d09b) --- sys/amd64/linux/linux_sysvec.c | 12 +++++++++++- sys/amd64/linux32/linux32_sysvec.c | 12 +++++++++++- sys/arm64/linux/linux_sysvec.c | 12 +++++++++++- sys/i386/linux/linux_sysvec.c | 14 ++++++++++++-- sys/kern/kern_exec.c | 4 +--- sys/sys/sysent.h | 2 +- 6 files changed, 47 insertions(+), 9 deletions(-) diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index 5237e32b614d..bcc8cbf0b0bd 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -106,6 +106,8 @@ static void linux_set_syscall_retval(struct thread *td, int error); static int linux_fetch_syscall_args(struct thread *td); static void linux_exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack); +static int linux_on_exec_vmspace(struct proc *p, + struct image_params *imgp); static int linux_vsyscall(struct thread *td); #define LINUX_T_UNKNOWN 255 @@ -760,12 +762,20 @@ struct sysentvec elf_linux_sysvec = { .sv_schedtail = linux_schedtail, .sv_thread_detach = linux_thread_detach, .sv_trap = linux_vsyscall, - .sv_onexec = linux_on_exec, + .sv_onexec = linux_on_exec_vmspace, .sv_onexit = linux_on_exit, .sv_ontdexit = linux_thread_dtor, .sv_setid_allowed = &linux_setid_allowed_query, }; +static int +linux_on_exec_vmspace(struct proc *p, struct image_params *imgp) +{ + + linux_on_exec(p, imgp); + return (0); +} + static void linux_vdso_install(void *param) { diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index 398ac51d4203..2a3fde78852d 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -111,6 +111,8 @@ static int linux_copyout_strings(struct image_params *imgp, static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask); static void linux_exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack); +static int linux_on_exec_vmspace(struct proc *p, + struct image_params *imgp); static void linux32_fixlimit(struct rlimit *rl, int which); static bool linux32_trans_osrel(const Elf_Note *note, int32_t *osrel); static void linux_vdso_install(void *param); @@ -929,12 +931,20 @@ struct sysentvec elf_linux_sysvec = { .sv_schedtail = linux_schedtail, .sv_thread_detach = linux_thread_detach, .sv_trap = NULL, - .sv_onexec = linux_on_exec, + .sv_onexec = linux_on_exec_vmspace, .sv_onexit = linux_on_exit, .sv_ontdexit = linux_thread_dtor, .sv_setid_allowed = &linux_setid_allowed_query, }; +static int +linux_on_exec_vmspace(struct proc *p, struct image_params *imgp) +{ + + linux_on_exec(p, imgp); + return (0); +} + static void linux_vdso_install(void *param) { diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c index 1b815b8ac0f2..44f4ffab5286 100644 --- a/sys/arm64/linux/linux_sysvec.c +++ b/sys/arm64/linux/linux_sysvec.c @@ -89,6 +89,8 @@ static void linux_set_syscall_retval(struct thread *td, int error); static int linux_fetch_syscall_args(struct thread *td); static void linux_exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack); +static int linux_on_exec_vmspace(struct proc *p, + struct image_params *imgp); /* DTrace init */ LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE); @@ -431,12 +433,20 @@ struct sysentvec elf_linux_sysvec = { .sv_trap = NULL, .sv_hwcap = &elf_hwcap, .sv_hwcap2 = &elf_hwcap2, - .sv_onexec = linux_on_exec, + .sv_onexec = linux_on_exec_vmspace, .sv_onexit = linux_on_exit, .sv_ontdexit = linux_thread_dtor, .sv_setid_allowed = &linux_setid_allowed_query, }; +static int +linux_on_exec_vmspace(struct proc *p, struct image_params *imgp) +{ + + linux_on_exec(p, imgp); + return (0); +} + static void linux_vdso_install(const void *param) { diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index 92bf6a7bed24..b1a5fb5ba062 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -94,6 +94,8 @@ static int linux_fixup_elf(uintptr_t *stack_base, static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask); static void linux_exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack); +static int linux_on_exec_vmspace(struct proc *p, + struct image_params *imgp); static int linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base); static bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel); @@ -834,7 +836,7 @@ struct sysentvec linux_sysvec = { .sv_schedtail = linux_schedtail, .sv_thread_detach = linux_thread_detach, .sv_trap = NULL, - .sv_onexec = linux_on_exec, + .sv_onexec = linux_on_exec_vmspace, .sv_onexit = linux_on_exit, .sv_ontdexit = linux_thread_dtor, .sv_setid_allowed = &linux_setid_allowed_query, @@ -877,12 +879,20 @@ struct sysentvec elf_linux_sysvec = { .sv_schedtail = linux_schedtail, .sv_thread_detach = linux_thread_detach, .sv_trap = NULL, - .sv_onexec = linux_on_exec, + .sv_onexec = linux_on_exec_vmspace, .sv_onexit = linux_on_exit, .sv_ontdexit = linux_thread_dtor, .sv_setid_allowed = &linux_setid_allowed_query, }; +static int +linux_on_exec_vmspace(struct proc *p, struct image_params *imgp) +{ + + linux_on_exec(p, imgp); + return (0); +} + static void linux_vdso_install(void *param) { diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index e6081cba7a4b..f62c4582e89a 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1196,9 +1196,7 @@ exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv) } } - if (sv->sv_onexec != NULL) - sv->sv_onexec(p, imgp); - return (0); + return (sv->sv_onexec != NULL ? sv->sv_onexec(p, imgp) : 0); } /* diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index f02383bacdbc..7696879112e5 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -153,7 +153,7 @@ struct sysentvec { const char *(*sv_machine_arch)(struct proc *); vm_offset_t sv_fxrng_gen_base; void (*sv_onexec_old)(struct thread *td); - void (*sv_onexec)(struct proc *, struct image_params *); + int (*sv_onexec)(struct proc *, struct image_params *); void (*sv_onexit)(struct proc *); void (*sv_ontdexit)(struct thread *td); int (*sv_setid_allowed)(struct thread *td,