diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 4ba7495cf7d5453b99b487cc89845f318cfe87b2..5314ef0cfb6355611a23db9cf1d3226ed2490239 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -730,6 +730,7 @@ static int load_elf_binary(struct linux_binprm *bprm) struct elfhdr interp_elf_ex; } *loc; struct arch_elf_state arch_state = INIT_ARCH_ELF_STATE; + const int snapshot_randomize_va_space = READ_ONCE(randomize_va_space); loff_t pos; loc = kmalloc(sizeof(*loc), GFP_KERNEL); @@ -897,7 +898,7 @@ static int load_elf_binary(struct linux_binprm *bprm) if (elf_read_implies_exec(loc->elf_ex, executable_stack)) current->personality |= READ_IMPLIES_EXEC; - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space) + if (!(current->personality & ADDR_NO_RANDOMIZE) && snapshot_randomize_va_space) current->flags |= PF_RANDOMIZE; setup_new_exec(bprm); @@ -1161,7 +1162,7 @@ static int load_elf_binary(struct linux_binprm *bprm) current->mm->end_data = end_data; current->mm->start_stack = bprm->p; - if ((current->flags & PF_RANDOMIZE) && (randomize_va_space > 1)) { + if ((current->flags & PF_RANDOMIZE) && (snapshot_randomize_va_space > 1)) { /* * For architectures with ELF randomization, when executing * a loader directly (i.e. no interpreter listed in ELF