From nobody Wed Nov 25 15:20:45 2026 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 4jZNfj2Y8yz71fPV for ; Wed, 25 Nov 2026 15:20:45 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jZNfj1ts2z4gt7 for ; Wed, 25 Nov 2026 15:20:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795620045; 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=vA3R/KdOED/zSsOXKzfeBWsiyDvm62vHFEorX3Fna5Q=; b=CrIv6PxWqpsmgb4ZI28QroCrri9cjpVeLiucb+TlQ4tR622RYjVZWl/OF8YBTZT0WjZJCH PNCWeVIdpIBL70hDT7MR/z7PADrjUuIX+V4O0rA1vaomkdDiz2Yj2BTi8bsRxIooRXfYQE U6xop4In+cGZ/VlVz2cY5LyFv+C88ZL4zPuVMBQ/3qqSshzQbWuYv0p3YRkCN/Mfg3oYYA W4uwByHyDxGlAgTrBWv4f1RhteIjtXjMf6FCKEigpPqaKxNTRyctCahDGpXTY8+WDmY8wI 7noVdzRP935o6I/iewUeIeHpIX6R+WgmUFnCRIRVwAL9IikDCGfV4+Ei74GYRg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795620045; b=reGPPC6+M9hRuByoU+ZLqhLWGNXIWsKgDgHt5616mN/RbcsiND89AcwBxFMNGqP4jl1exY 1Q9vK0MNALDM1g6SQiEk0pNqKGjcrAI7O3KWDWZdkamgqJhQVLNB3+WLHPqfxvADt0WGc/ yI1oITj7oCQYkGJSoFBDqoj8C3Y5E9WzK0FZnlvE9rHD0hXdfRkLupT8uaxtGHcvEjnpc7 GPAlQw/uY7wABOYHel9/EoO3TEWlf5rwaP2u6Q4oJnA14CMbCX7jDGeHtr+Ksz8g6saIkE DbsqWcLTs85DXRqscROkWrNon+/tHrbjyb+a6GSadRCkH5x0Nh/C+5JvEk3Tgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795620045; 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=vA3R/KdOED/zSsOXKzfeBWsiyDvm62vHFEorX3Fna5Q=; b=jPp7lVqXmcjQSev/y4Ff71sdzew79Khp50tm0xU7Sqam1IeAQBy+y+MQ4QGLtNFqTp/S/c PBA4PUPa8CwobIzyCqzsS7vx1w1d3MFQUrLrB+uWpwtxIlWgtvZEQCuLjPMcpDnvcDZ9UA 2hZCCJWvVV+5xZ2dq1woOKvlDCxUwlG5PAIvGZRuLtbTYAGI5PTU6DDj1QEY3+8DvrHeeJ C8LYUWcuDqX1EqCgxg26maVrdBcCWH7wFeYNxhDZyKsWikrpBCGJ6Dktk3sztRYUGJT4PL BoDPBRKV5xPB6Q+y7FnllOXR+ZhongDpzXWYpV0+UZIDvuvoMrEUWCeIsU1C5w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jZNfj1YCKzVxl for ; Wed, 25 Nov 2026 15:20:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id d089 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 25 Nov 2026 15:20:45 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 884e1a00151d - main - imgact_elf: Pass program headers to the sv_protect hook List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 884e1a00151d181e5dd1ba9d83c1adcffd25e5e8 Auto-Submitted: auto-generated Date: Wed, 25 Nov 2026 15:20:45 +0000 Message-Id: <6b06fccd.d089.4f7bd2e8@gitrepo.freebsd.org> The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=884e1a00151d181e5dd1ba9d83c1adcffd25e5e8 commit 884e1a00151d181e5dd1ba9d83c1adcffd25e5e8 Author: Mark Johnston AuthorDate: 2026-11-25 15:17:44 +0000 Commit: Mark Johnston CommitDate: 2026-11-25 15:17:44 +0000 imgact_elf: Pass program headers to the sv_protect hook We handle program headers beyond the first page of the file, but arm64_exec_protect() wasn't updated to handle this. Pass the program header array directly to the sv_protect hook. Also fix a pre-existing bug: imgp->et_dyn_addr isn't the right base address to use for the SV_INTERP case. Reported by: alc Reviewed by: alc, kib Fixes: 804daf166406 ("imgact_elf: read program headers if not contained in the first page") Fixes: 670af174e27b ("arm64: Enable BTI in the kernel ELF loader") MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D61999 --- sys/arm64/arm64/elf_machdep.c | 10 ++++++---- sys/kern/imgact_elf.c | 4 ++-- sys/sys/sysent.h | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/sys/arm64/arm64/elf_machdep.c b/sys/arm64/arm64/elf_machdep.c index 9e8d781f5ea1..998c39c10ed4 100644 --- a/sys/arm64/arm64/elf_machdep.c +++ b/sys/arm64/arm64/elf_machdep.c @@ -73,7 +73,8 @@ struct arm64_addr_mask elf64_addr_mask = { struct arm64_addr_mask elf64_addr_mask_14; #endif -static void arm64_exec_protect(struct image_params *, int); +static void arm64_exec_protect(struct image_params *, unsigned long, + const void *, int); static struct sysentvec elf64_freebsd_sysvec = { .sv_size = SYS_MAXSYSCALL, @@ -365,7 +366,8 @@ gnu_property_cb(const Elf_Note *note, void *arg0, bool *res) } static void -arm64_exec_protect(struct image_params *imgp, int flags __unused) +arm64_exec_protect(struct image_params *imgp, unsigned long base_addr, + const void *_phdr, int flags __unused) { const Elf_Ehdr *hdr; const Elf_Phdr *phdr; @@ -378,7 +380,7 @@ arm64_exec_protect(struct image_params *imgp, int flags __unused) return; hdr = (const Elf_Ehdr *)imgp->image_header; - phdr = (const Elf_Phdr *)(imgp->image_header + hdr->e_phoff); + phdr = (const Elf_Phdr *)_phdr; found = false; for (i = 0; i < hdr->e_phnum; i++) { @@ -396,7 +398,7 @@ arm64_exec_protect(struct image_params *imgp, int flags __unused) if (phdr[i].p_type != PT_LOAD || phdr[i].p_memsz == 0) continue; - sva = phdr[i].p_vaddr + imgp->et_dyn_addr; + sva = phdr[i].p_vaddr + base_addr; eva = sva + phdr[i].p_memsz; pmap_bti_set(vmspace_pmap(imgp->proc->p_vmspace), sva, eva); } diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 2dd12d64b5bb..777075f82acf 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -875,7 +875,7 @@ __elfN(load_interp_file)(struct thread *td, const char *file, u_long *addr, goto fail; if (imgp->proc->p_sysent->sv_protect != NULL) - imgp->proc->p_sysent->sv_protect(imgp, SVP_INTERP); + imgp->proc->p_sysent->sv_protect(imgp, rbase, phdr, SVP_INTERP); *addr = base_addr; *entry = (unsigned long)hdr->e_entry + rbase; @@ -1405,7 +1405,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) imgp->entry_addr = entry; if (sv->sv_protect != NULL) - sv->sv_protect(imgp, SVP_IMAGE); + sv->sv_protect(imgp, imgp->et_dyn_addr, phdr, SVP_IMAGE); if (interp != NULL) { VOP_UNLOCK(imgp->vp); diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index b250ec1f7a70..c0167ec4c49b 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -152,7 +152,8 @@ 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_protect)(struct image_params *, unsigned long, + const void *, int); void (*sv_onexit)(struct proc *); void (*sv_ontdexit)(struct thread *td); int (*sv_setid_allowed)(struct thread *td,