linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs: binfmt_elf_efpic: don't use missing interpreter's properties
@ 2024-01-18 15:06 Max Filippov
  2024-02-05 14:31 ` Max Filippov
  2024-02-05 16:15 ` Kees Cook
  0 siblings, 2 replies; 3+ messages in thread
From: Max Filippov @ 2024-01-18 15:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Chris Zankel, Alexander Viro, Christian Brauner, Eric Biederman,
	Kees Cook, linux-fsdevel, linux-mm, Greg Ungerer,
	Geert Uytterhoeven, Max Filippov

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>
---
 fs/binfmt_elf_fdpic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index be4e7ac3efbc..f6d72fe3998c 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -322,7 +322,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
 	else
 		executable_stack = EXSTACK_DEFAULT;
 
-	if (stack_size == 0) {
+	if (stack_size == 0 && interp_params.flags & ELF_FDPIC_FLAG_PRESENT) {
 		stack_size = interp_params.stack_size;
 		if (interp_params.flags & ELF_FDPIC_FLAG_EXEC_STACK)
 			executable_stack = EXSTACK_ENABLE_X;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-05 16:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-18 15:06 [PATCH] fs: binfmt_elf_efpic: don't use missing interpreter's properties Max Filippov
2024-02-05 14:31 ` Max Filippov
2024-02-05 16:15 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).