aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2026-07-08 02:56:38 +0000
committerKyle Evans <kevans@FreeBSD.org>2026-07-08 02:56:38 +0000
commitf5329a0d14712ae990f650286a6d5a04617c7cb3 (patch)
treea4bf7431811af681ecc95723dc0db7b4d2f14553
parent407c7c339adb429efcb6658accd16399031c34ca (diff)
kern: imgact: fix imgp->interpreted
This is a mask, so the new value should have taken the next bit to avoid breaking a shell script that's interpreted by a binmisc-activated interpreter. Add a brief note that the new value is only used within the ELF activator. Fixes: 389c124fecb0 ("imgact_elf.c indicate that interpreter [...]") Reported by: "polyduekes" on discord, madpilot Reviewed by: kib, sjg (both previous version) Differential Revision: https://reviews.freebsd.org/D58063
-rw-r--r--sys/kern/imgact_elf.c4
-rw-r--r--sys/kern/kern_exec.c3
-rw-r--r--sys/sys/imgact.h2
3 files changed, 4 insertions, 5 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index a0dc96e74ed6..7c78d66b3648 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -823,8 +823,8 @@ __elfN(load_interp_file)(struct thread *td, const char *file, u_long *addr,
imgp->td = td;
imgp->proc = td->td_proc;
imgp->attr = attr;
- imgp->interpreted = IMGACT_INTERP_IGNORE; /* ignored by do_execve */
-
+ imgp->interpreted = IMGACT_INTERP_ELF; /* ignored by do_execve */
+
NDINIT(nd, LOOKUP, ISOPEN | FOLLOW | LOCKSHARED | LOCKLEAF,
UIO_SYSSPACE, file);
if ((error = namei(nd)) != 0) {
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index b6f2848f800c..03a05c6cc041 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -750,8 +750,7 @@ interpret:
* Special interpreter operation, cleanup and loop up to try to
* activate the interpreter.
*/
- if (imgp->interpreted != 0 &&
- imgp->interpreted != IMGACT_INTERP_IGNORE) {
+ if ((imgp->interpreted & ~IMGACT_INTERP_ELF) != 0) {
exec_unmap_first_page(imgp);
/*
* The text reference needs to be removed for scripts.
diff --git a/sys/sys/imgact.h b/sys/sys/imgact.h
index bf0453beec1f..155db3c7cb6b 100644
--- a/sys/sys/imgact.h
+++ b/sys/sys/imgact.h
@@ -86,7 +86,7 @@ struct image_params {
struct ucred *newcred; /* new credentials if changing */
#define IMGACT_SHELL 0x1
#define IMGACT_BINMISC 0x2
-#define IMGACT_INTERP_IGNORE 0x3
+#define IMGACT_INTERP_ELF 0x4 /* only used within the ELF activator */
unsigned char interpreted; /* mask of interpreters that have run */
bool credential_setid; /* true if becoming setid */
bool vmspace_destroyed; /* we've blown away original vm space */