Commit 2813e143 authored by David Mosberger's avatar David Mosberger Committed by Linus Torvalds

[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: default avatarLinus Torvalds <torvalds@osdl.org>
parent 6ad38b90
......@@ -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 */
......
......@@ -120,10 +120,10 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
#define SET_PERSONALITY(ex, ibcs2) do { } while (0)
/*
* A legacy binary, when loaded by the ELF loader, will have the
* READ_IMPLIES_EXEC personality flag set automatically:
* An executable for which elf_read_implies_exec() returns TRUE will
* have the READ_IMPLIES_EXEC personality flag set automatically.
*/
#define LEGACY_BINARIES
#define elf_read_implies_exec_binary(ex, have_pt_gnu_stack) (!(have_pt_gnu_stack))
extern int dump_task_regs (struct task_struct *, elf_gregset_t *);
extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *);
......
......@@ -4,6 +4,13 @@
#include <linux/types.h>
#include <asm/elf.h>
#ifndef elf_read_implies_exec
/* Executables for which elf_read_implies_exec() returns TRUE will
have the READ_IMPLIES_EXEC personality flag set automatically.
Override in asm/elf.h as needed. */
# define elf_read_implies_exec(ex, have_pt_gnu_stack) 0
#endif
/* 32-bit ELF base types. */
typedef __u32 Elf32_Addr;
typedef __u16 Elf32_Half;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment