summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2026-07-21 16:13:58 +0200
committerChristian Brauner <brauner@kernel.org>2026-08-03 10:08:46 +0200
commit2a4d517681e105dcfabd7ec7d2dae6285c593ee3 (patch)
treefc3ba94ca9e121038e833757e58575eacda1eb8f
parent73808bc5fd98eb055c12fa9afd954cea5417817f (diff)
downloadlinux-2a4d517681e105dcfabd7ec7d2dae6285c593ee3.tar.gz
linux-2a4d517681e105dcfabd7ec7d2dae6285c593ee3.zip
binfmt_elf: consume a stashed PT_INTERP substitute
When a binfmt_misc loader entry stashed bprm->loader use it instead of opening the path named in PT_INTERP. The substitution deliberately changes as little as possible. Ownership transfers into the local interpreter reference which the existing success and error paths already release. A binary without PT_INTERP has nothing to substitute for. Drop the override at the end of the segment scan and load the binary natively. Nothing sets bprm->loader yet. Link: https://patch.msgid.link/20260721-work-bpf-binfmt_misc-ptinterp-v2-16-e57866e4ae0f@kernel.org Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
-rw-r--r--fs/binfmt_elf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index be8fd437b5a3..00ff35cad441 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -901,7 +901,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
if (elf_interpreter[elf_ppnt->p_filesz - 1] != '\0')
goto out_free_interp;
- interpreter = open_exec(elf_interpreter);
+ interpreter = bprm_open_interpreter(bprm, elf_interpreter);
kfree(elf_interpreter);
retval = PTR_ERR(interpreter);
if (IS_ERR(interpreter))
@@ -932,6 +932,9 @@ out_free_interp:
goto out_free_ph;
}
+ /* No PT_INTERP to substitute for: the override does not apply. */
+ bprm_drop_loader(bprm);
+
elf_ppnt = elf_phdata;
for (i = 0; i < elf_ex->e_phnum; i++, elf_ppnt++)
switch (elf_ppnt->p_type) {