binfmt_elf: fix checks for bad address
Subsystems (2)
PATCH 1/1 binfmt_elf: fix checks for bad address
Fix check for bad address; use macro instead of open-coding two checks.
Taken from RHEL4 kernel update.
Signed-off-by Chuck Ebbert <[email protected]>
fs/binfmt_elf.c +3 -3
@@ -84,7 +84,7 @@ static struct linux_binfmt elf_format = .min_coredump = ELF_EXEC_PAGESIZE }; -#define BAD_ADDR (x) ((unsigned long)(x) > TASK_SIZE) +#define BAD_ADDR (x) ((unsigned long)(x) >= TASK_SIZE)static int set_brk (unsigned long start,unsigned long end) {
@@ -394,7 +394,7 @@ static unsigned long load_elf_interp(str* <= p_memsize so it's only necessary to check p_memsz. */ k = load_addr + eppnt->p_vaddr; -if (k >TASK_SIZE || +if (BAD_ADDR (k) || eppnt->p_filesz > eppnt->p_memsz || eppnt->p_memsz >TASK_SIZE ||TASK_SIZE - eppnt->p_memsz < k) {
@@ -888,7 +888,7 @@ static int load_elf_binary(struct linux_* allowed task size. Note that p_filesz must always be * <= p_memsz so it is only necessary to check p_memsz. */ -if (k >TASK_SIZE || elf_ppnt->p_filesz > elf_ppnt->p_memsz || +if (BAD_ADDR (k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz || elf_ppnt->p_memsz >TASK_SIZE ||TASK_SIZE - elf_ppnt->p_memsz < k) {/* set_brk can never work. Avoid overflows. */
Signature · 2 lines
Chuck "You can't read a newspaper if you can't read." --George W. Bush
fs/binfmt_elf.c static struct linux_binfmt elf_format = · line 87
Quoted 2 lines · On Tue, 20 Jun 2006 00:55:24 -0400 Chuck Ebbert <[email protected]>…
fs/binfmt_elf.c +1
-1-#define BAD_ADDR (x) ((unsigned long)(x) > TASK_SIZE) +#define BAD_ADDR (x) ((unsigned long)(x) >= TASK_SIZE)
Convince us that this is correct for all the other users of BAD_ADDR() in this file.