From nobody Fri Nov 10 10:06:59 2023 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 4SRZHR5H8Mz501ZM; Fri, 10 Nov 2023 10:06:59 +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 4SRZHR3WVfz3Jf1; Fri, 10 Nov 2023 10:06:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699610819; 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=IHiwvdBb6KIdRRuOudGbsFCCAsPt/FLbDJGWiYNoM6k=; b=UMrKMYVH5harV2EA5+NtFehcEvcip/s1s2K47TQOd6eMsi+GO8pp/b22CWF2c8i4L0mmo2 TRPC7gLzeTuTUilUnVoQK/z2cY12eZpDgHHDwmyQCT0B5qkv6EcDrHt6ZKJx+v2ctjhX5u jue2SQr5s1+lgcp6P3A8sp2sVzB8uL/5f4oUwVLbVXbfB+GE5cPFS+9Z12R4oL9X50S0cf Pvr/fn01iJi7cKCFO/V1P+siVCxteX2VqftJLabHCUrvnjz3mWyXQfMNusGXuDT8vO6ZVI y4VPTXzUcffilp3VgZIeWUS3SUSqQ8f2/a6dJ2DgW57cCVvBdh10VJsCLlEGBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699610819; 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=IHiwvdBb6KIdRRuOudGbsFCCAsPt/FLbDJGWiYNoM6k=; b=Exn+3GTmnEl+QwsliMQUmcteL3H/EgEPES3ACSByiag1VT3oX0poZcWgjG+2B5/mIvMT7d 2Wurt84LYw2ad470IASMBpUQTjJyTeXFusUPDDSJ1qIQFil7TCNmmRlhjPtnNK/K/PDuMR NDATpw1VXB8T+bdT8sfyiP9UHBOWbBAqyUVrQBHTvX3zBFq3RHbvOZVCrQZPdgDUlG1Aw4 WrSNUHqgfTqDvwXkejZ1pr/8uW7DYJOn6DM8VZtanOersc3hc+erUXeAl2a36XuD+n+peb pHBjh61beRcf14V1gJGTSM+cBGLNZiQswxEIGzlcYOh9wMLT4ae1ArMk+IPuXg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699610819; a=rsa-sha256; cv=none; b=tafmK7k/ST7NqSLX5K++E6teHjEOmIkTb1AQKxTv8ZP7S1aeDq5O+r9Hdh7e+5vQZ3oqCf +ybcWYiPxMgiT6ZEQbVQZEpBElKdkWs4hlMT2TaiRm48y64oXVVYfZcbzKMpqd4hHsp9sr YDut7v2eAPJxZgedozUu7cX5n4MEwJ1UccV01tpZ/a8POPToImdiwHbszyS4rk4mWkk6R6 VTuEqcjpwgI3gMai4DLj2lf1cS7lqRtg3FisfTxpvC3qoBvUl84z8XG1+9DV4ijArfK6zS fBottyQbTyzopfX4PeKXZPoBaNJxb0ivkwsuLrWwDu/8RzlLYfOJO55ha9hrQA== 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 4SRZHR2bVBztkw; Fri, 10 Nov 2023 10:06:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AAA6x7O016751; Fri, 10 Nov 2023 10:06:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AAA6xxF016748; Fri, 10 Nov 2023 10:06:59 GMT (envelope-from git) Date: Fri, 10 Nov 2023 10:06:59 GMT Message-Id: <202311101006.3AAA6xxF016748@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: eb32c1c75ab0 - main - sysent: Add sv_protect 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: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: eb32c1c75ab0d8518a04ab18d46e82804b31d055 Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=eb32c1c75ab0d8518a04ab18d46e82804b31d055 commit eb32c1c75ab0d8518a04ab18d46e82804b31d055 Author: Andrew Turner AuthorDate: 2023-11-02 09:49:27 +0000 Commit: Andrew Turner CommitDate: 2023-11-10 09:57:45 +0000 sysent: Add sv_protect To allow for architecture specific protections add sv_protect to struct sysent. This can be used to apply these after the executable is loaded into the new address space. Reviewed by: kib Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D42440 --- sys/kern/imgact_elf.c | 6 ++++++ sys/sys/sysent.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index f361920e16d5..047bde3c250b 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -862,6 +862,9 @@ __elfN(load_file)(struct proc *p, const char *file, u_long *addr, if (error != 0) goto fail; + if (p->p_sysent->sv_protect != NULL) + p->p_sysent->sv_protect(imgp, SVP_INTERP); + *addr = base_addr; *entry = (unsigned long)hdr->e_entry + rbase; @@ -1369,6 +1372,9 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) entry = (u_long)hdr->e_entry + imgp->et_dyn_addr; imgp->entry_addr = entry; + if (sv->sv_protect != NULL) + sv->sv_protect(imgp, SVP_IMAGE); + if (interp != NULL) { VOP_UNLOCK(imgp->vp); if ((map->flags & MAP_ASLR) != 0) { diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index a23c338f9ce2..c582ed494be9 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -149,6 +149,7 @@ struct sysentvec { vm_offset_t sv_fxrng_gen_offset; void (*sv_onexec_old)(struct thread *td); int (*sv_onexec)(struct proc *, struct image_params *); + void (*sv_protect)(struct image_params *, int); void (*sv_onexit)(struct proc *); void (*sv_ontdexit)(struct thread *td); int (*sv_setid_allowed)(struct thread *td, @@ -187,6 +188,10 @@ struct sysentvec { #define SVC_NOCOMPRESS 0x00000002 /* disable compression. */ #define SVC_ALL 0x00000004 /* dump everything */ +/* sv_protect flags */ +#define SVP_IMAGE 0x00000001 +#define SVP_INTERP 0x00000002 + #ifdef _KERNEL extern struct sysentvec aout_sysvec; extern struct sysent sysent[];