diff options
author | David Mosberger <davidm@napali.hpl.hp.com> | 2004-07-22 20:26:36 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-07-22 20:26:36 -0700 |
commit | 2813e143a72dc73be5443cca386d7849088aad7b (patch) | |
tree | bf8bcc43161ff3899f7e9186099ab3e344333c8a /fs | |
parent | 6ad38b905d0b5b488d01d4ef3980bd9c1d398019 (diff) | |
download | history-2813e143a72dc73be5443cca386d7849088aad7b.tar.gz |
[PATCH] NX: allow architectures to select legacy mode dynamically
On some platforms, you'll want to support READ_IMPLIES_EXEC differently
depending on personality (e.g, native binary vs. x86 binary).
This supports that (and makes the code more readable while at it) by
replacing the old architecture-specific fixed LEGACY_BINARIES macro
define with a architecture-specific "elf_read_implies_exec_binary()"
helper function.
For now, x86 is the only user, and sets the "read implies exec" bit for
legacy apps. ia64 and x86-64 are likely to want to do their own thing.
Acked by Ingo.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/binfmt_elf.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 24f057772f430c..55082e5ecaeddb 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -492,7 +492,7 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs) struct exec interp_ex; char passed_fileno[6]; struct files_struct *files; - int executable_stack = EXSTACK_DEFAULT; + int have_pt_gnu_stack, executable_stack = EXSTACK_DEFAULT; unsigned long def_flags = 0; /* Get the exec-header */ @@ -627,10 +627,7 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs) executable_stack = EXSTACK_DISABLE_X; break; } -#ifdef LEGACY_BINARIES - if (i == elf_ex.e_phnum) - current->personality |= READ_IMPLIES_EXEC; -#endif + have_pt_gnu_stack = (i < elf_ex.e_phnum); /* Some simple consistency checks for the interpreter */ if (elf_interpreter) { @@ -703,6 +700,8 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs) /* Do this immediately, since STACK_TOP as used in setup_arg_pages may depend on the personality. */ SET_PERSONALITY(elf_ex, ibcs2_interpreter); + if (elf_read_implies_exec(elf_ex, have_pt_gnu_stack)) + current->personality |= READ_IMPLIES_EXEC; /* Do this so that we can load the interpreter, if need be. We will change some of these later */ |