Skip to contentSkip to conversation

ELF: fix ->start_code calculation

PATCH Applied Alexey Dobriyan 1 participant 1 message Dec 8, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ELF: fix ->start_code calculation

Only executable segments should be accounted to ->start_code just like they do to ->end_code (correctly).

---

 fs/binfmt_elf.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/binfmt_elf.c +1 -1
@@ -997,7 +997,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
 			}
 		}
 		k = elf_ppnt->p_vaddr;
-		if (k < start_code)
+		if ((elf_ppnt->p_flags & PF_X) && k < start_code)
 			start_code = k;
 		if (start_data < k)
 			start_data = k;