Skip to content

Commit 15fd1dc

Browse files
jcmvbkbckees
authored andcommitted
fs: binfmt_elf_efpic: don't use missing interpreter's properties
Static FDPIC executable may get an executable stack even when it has non-executable GNU_STACK segment. This happens when STACK segment has rw permissions, but does not specify stack size. In that case FDPIC loader uses permissions of the interpreter's stack, and for static executables with no interpreter it results in choosing the arch-default permissions for the stack. Fix that by using the interpreter's properties only when the interpreter is actually used. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Link: https://lore.kernel.org/r/20240118150637.660461-1-jcmvbkbc@gmail.com Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent 41bccc9 commit 15fd1dc

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/binfmt_elf_fdpic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
320320
else
321321
executable_stack = EXSTACK_DEFAULT;
322322

323-
if (stack_size == 0) {
323+
if (stack_size == 0 && interp_params.flags & ELF_FDPIC_FLAG_PRESENT) {
324324
stack_size = interp_params.stack_size;
325325
if (interp_params.flags & ELF_FDPIC_FLAG_EXEC_STACK)
326326
executable_stack = EXSTACK_ENABLE_X;

0 commit comments

Comments
 (0)