|
@@ -170,6 +170,9 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm,
|
|
|
unsigned long stack_size, entryaddr;
|
|
|
#ifdef ELF_FDPIC_PLAT_INIT
|
|
|
unsigned long dynaddr;
|
|
|
+#endif
|
|
|
+#ifndef CONFIG_MMU
|
|
|
+ unsigned long stack_prot;
|
|
|
#endif
|
|
|
struct file *interpreter = NULL; /* to shut gcc up */
|
|
|
char *interpreter_name = NULL;
|
|
@@ -316,6 +319,8 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm,
|
|
|
* defunct, deceased, etc. after this point we have to exit via
|
|
|
* error_kill */
|
|
|
set_personality(PER_LINUX_FDPIC);
|
|
|
+ if (elf_read_implies_exec(&exec_params.hdr, executable_stack))
|
|
|
+ current->personality |= READ_IMPLIES_EXEC;
|
|
|
set_binfmt(&elf_fdpic_format);
|
|
|
|
|
|
current->mm->start_code = 0;
|
|
@@ -377,9 +382,13 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm,
|
|
|
if (stack_size < PAGE_SIZE * 2)
|
|
|
stack_size = PAGE_SIZE * 2;
|
|
|
|
|
|
+ stack_prot = PROT_READ | PROT_WRITE;
|
|
|
+ if (executable_stack == EXSTACK_ENABLE_X ||
|
|
|
+ (executable_stack == EXSTACK_DEFAULT && VM_STACK_FLAGS & VM_EXEC))
|
|
|
+ stack_prot |= PROT_EXEC;
|
|
|
+
|
|
|
down_write(¤t->mm->mmap_sem);
|
|
|
- current->mm->start_brk = do_mmap(NULL, 0, stack_size,
|
|
|
- PROT_READ | PROT_WRITE | PROT_EXEC,
|
|
|
+ current->mm->start_brk = do_mmap(NULL, 0, stack_size, stack_prot,
|
|
|
MAP_PRIVATE | MAP_ANONYMOUS |
|
|
|
MAP_UNINITIALIZED | MAP_GROWSDOWN,
|
|
|
0);
|