From dc415f8012fb3e5f2d23bc13c06f794ca0835ea9 Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Wed, 2 Nov 2011 13:37:41 -0700 Subject: [PATCH] --- yaml --- r: 273229 b: refs/heads/master c: a3defbe5c337dbc6da911f8cc49ae3cc3b49b453 h: refs/heads/master i: 273227: 92878dc78a6085b70454905545b37475cdff358b v: v3 --- [refs] | 2 +- trunk/fs/binfmt_elf.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 70e9f6a3f9d1..e9010b2a0426 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b35a35b556f5e6b7993ad0baf20173e75c09ce8c +refs/heads/master: a3defbe5c337dbc6da911f8cc49ae3cc3b49b453 diff --git a/trunk/fs/binfmt_elf.c b/trunk/fs/binfmt_elf.c index dd0fdfc56d38..21ac5ee4b43f 100644 --- a/trunk/fs/binfmt_elf.c +++ b/trunk/fs/binfmt_elf.c @@ -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