mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-12-01 16:31:34 -05:00
binfmt_elf: fix PIE execution with randomization disabled
The case of address space randomization being disabled in runtime through randomize_va_space sysctl is not treated properly in load_elf_binary(), resulting in SIGKILL coming at exec() time for certain PIE-linked binaries in case the randomization has been disabled at runtime prior to calling exec(). Handle the randomize_va_space == 0 case the same way as if we were not supporting .text randomization at all. Based on original patch by H.J. Lu and Josh Boyer. Signed-off-by: Jiri Kosina <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Russell King <[email protected]> Cc: H.J. Lu <[email protected]> Cc: <[email protected]> Tested-by: Josh Boyer <[email protected]> Acked-by: Nicolas Pitre <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
b35a35b556
commit
a3defbe5c3
1 changed files with 10 additions and 1 deletions
|
|
@ -795,7 +795,16 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
|
|||
* might try to exec. This is because the brk will
|
||||
* follow the loader, and is not movable. */
|
||||
#if defined(CONFIG_X86) || defined(CONFIG_ARM)
|
||||
load_bias = 0;
|
||||
/* Memory randomization might have been switched off
|
||||
* in runtime via sysctl.
|
||||
* If that is the case, retain the original non-zero
|
||||
* load_bias value in order to establish proper
|
||||
* non-randomized mappings.
|
||||
*/
|
||||
if (current->flags & PF_RANDOMIZE)
|
||||
load_bias = 0;
|
||||
else
|
||||
load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
|
||||
#else
|
||||
load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue