--- fs/binfmt_elf_fdpic.c.orig +++ fs/binfmt_elf_fdpic.c @@ -103,14 +103,27 @@ core_initcall(init_elf_fdpic_binfmt); module_exit(exit_elf_fdpic_binfmt); +static int is_fdpic(struct elfhdr *hdr) +{ +#ifdef CONFIG_MMU + return 1; +#else + return elf_check_fdpic(hdr); +#endif +} + static int is_elf_fdpic(struct elfhdr *hdr, struct file *file) { if (memcmp(hdr->e_ident, ELFMAG, SELFMAG) != 0) return 0; if (hdr->e_type != ET_EXEC && hdr->e_type != ET_DYN) return 0; - if (!elf_check_arch(hdr) || !elf_check_fdpic(hdr)) + if (!elf_check_arch(hdr)) return 0; +#ifdef CONFIG_MMU + if (!elf_check_fdpic(hdr)) + return 0; +#endif if (!file->f_op->mmap) return 0; return 1; @@ -269,7 +282,7 @@ } - if (elf_check_const_displacement(&exec_params.hdr)) + if (elf_check_const_displacement(&exec_params.hdr) || !is_fdpic(&exec_params.hdr)) exec_params.flags |= ELF_FDPIC_FLAG_CONSTDISP; /* perform insanity checks on the interpreter */ @@ -306,9 +319,9 @@ retval = -ENOEXEC; if (stack_size == 0) - goto error; + stack_size = 131072; - if (elf_check_const_displacement(&interp_params.hdr)) + if (elf_check_const_displacement(&interp_params.hdr) || !is_fdpic(&interp_params.hdr)) interp_params.flags |= ELF_FDPIC_FLAG_CONSTDISP; /* flush all traces of the currently running executable */ @@ -319,7 +332,8 @@ /* there's now no turning back... the old userspace image is dead, * defunct, deceased, etc. */ - set_personality(PER_LINUX_FDPIC); + if (is_fdpic(&exec_params.hdr)) + set_personality(PER_LINUX_FDPIC); if (elf_read_implies_exec(&exec_params.hdr, executable_stack)) current->personality |= READ_IMPLIES_EXEC; @@ -400,8 +414,6 @@ current->mm->brk = current->mm->start_brk; current->mm->context.end_brk = current->mm->start_brk; - current->mm->context.end_brk += - (stack_size > PAGE_SIZE) ? (stack_size - PAGE_SIZE) : 0; current->mm->start_stack = current->mm->start_brk + stack_size; #endif