hulk inclusion category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAU9NT CVE: CVE-2024-46826
--------------------------------
Due to the use of the compilation instruction -Wdeclaration-after-statment, declaring snapshot_randomize_va_space here will generate a compilation warning, so move it up.
Fixes: 2a97388a807b ("ELF: fix kernel.randomize_va_space double read") Signed-off-by: Gu Bowen gubowen5@huawei.com --- fs/binfmt_elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 9df3a3757025..5314ef0cfb63 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,6 @@ static int load_elf_binary(struct linux_binprm *bprm) if (elf_read_implies_exec(loc->elf_ex, executable_stack)) current->personality |= READ_IMPLIES_EXEC;
- const int snapshot_randomize_va_space = READ_ONCE(randomize_va_space); if (!(current->personality & ADDR_NO_RANDOMIZE) && snapshot_randomize_va_space) current->flags |= PF_RANDOMIZE;