From: David Howells <dhowells@redhat.com>
To: vapier.adi@gmail.com, rgetz@blackfin.uclinux.org, lethal@linux-sh.org
Cc: dhowells@redhat.com, gerg@uclinux.org,
uclinux-dist-devel@blackfin.uclinux.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] FDPIC: Ignore the loader's PT_GNU_STACK when calculating the stack size
Date: Wed, 01 Jul 2009 13:08:14 +0100 [thread overview]
Message-ID: <20090701120814.30741.10146.stgit@warthog.procyon.org.uk> (raw)
Ignore the loader's PT_GNU_STACK when calculating the stack size, and only
consider the executable's PT_GNU_STACK, assuming the executable has one.
Currently the behaviour is to take the largest stack size and use that, but
that means you can't reduce the stack size in the executable. The loader's
stack size should probably only be used when executing the loader directly.
WARNING: This patch is slightly dangerous - it may render a system inoperable
if the loader's stack size is larger than that of important executables, and
the system relies unknowingly on this increasing the size of the stack.
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/binfmt_elf_fdpic.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 81ca047..58c49fa 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -283,20 +283,23 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm,
}
stack_size = exec_params.stack_size;
- if (stack_size < interp_params.stack_size)
- stack_size = interp_params.stack_size;
-
if (exec_params.flags & ELF_FDPIC_FLAG_EXEC_STACK)
executable_stack = EXSTACK_ENABLE_X;
else if (exec_params.flags & ELF_FDPIC_FLAG_NOEXEC_STACK)
executable_stack = EXSTACK_DISABLE_X;
- else if (interp_params.flags & ELF_FDPIC_FLAG_EXEC_STACK)
- executable_stack = EXSTACK_ENABLE_X;
- else if (interp_params.flags & ELF_FDPIC_FLAG_NOEXEC_STACK)
- executable_stack = EXSTACK_DISABLE_X;
- else
+ else
executable_stack = EXSTACK_DEFAULT;
+ if (stack_size == 0) {
+ stack_size = interp_params.stack_size;
+ if (interp_params.flags & ELF_FDPIC_FLAG_EXEC_STACK)
+ executable_stack = EXSTACK_ENABLE_X;
+ else if (interp_params.flags & ELF_FDPIC_FLAG_NOEXEC_STACK)
+ executable_stack = EXSTACK_DISABLE_X;
+ else
+ executable_stack = EXSTACK_DEFAULT;
+ }
+
retval = -ENOEXEC;
if (stack_size == 0)
goto error;
next reply other threads:[~2009-07-01 12:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-01 12:08 David Howells [this message]
2009-07-01 16:02 ` Mike Frysinger
2009-07-01 16:48 ` [PATCH] FDPIC: Ignore the loader's PT_GNU_STACK when calculating the stack size [ver #2] David Howells
2009-07-01 16:49 ` [PATCH] FDPIC: Ignore the loader's PT_GNU_STACK when calculating the stack size David Howells
2009-07-01 16:49 ` [PATCH] FDPIC: Ignore the loader's PT_GNU_STACK when calculating the stack size [ver #2] David Howells
2009-07-02 17:21 ` [PATCH] FDPIC: Ignore the loader's PT_GNU_STACK when calculating the stack size Paul Mundt
2009-07-04 2:46 ` Pavel Machek
2009-07-08 11:01 ` David Howells
2009-07-04 3:34 ` Pavel Machek
2009-07-08 18:48 ` Mike Frysinger
2009-07-09 10:19 ` Pavel Machek
2009-07-09 10:59 ` David Howells
2009-07-11 21:30 ` Pavel Machek
2009-07-14 12:15 ` Mike Frysinger
2009-07-18 10:39 ` Pavel Machek
2009-07-18 19:11 ` Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090701120814.30741.10146.stgit@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=gerg@uclinux.org \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rgetz@blackfin.uclinux.org \
--cc=uclinux-dist-devel@blackfin.uclinux.org \
--cc=vapier.adi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®