mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
libbpf: Validate ELF symbol table entry size
elf_sym_iter_new() calculates the number of symbols by dividing the symbol table data size by sh_entsize. A malformed ELF file with a zero sh_entsize causes a division by zero. Reject symbol table sections with a zero entry size before calculating the number of symbols. Signed-off-by: Luis Vieira <luisflavieira@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20260916-libbpf-elf-entsize-fix-v1-1-cf181da33eab@gmail.com
This commit is contained in:
parent
7f2b0b57a8
commit
6892723c5e
|
|
@ -115,7 +115,7 @@ static int elf_sym_iter_new(struct elf_sym_iter *iter,
|
|||
return -ENOENT;
|
||||
}
|
||||
|
||||
if (!gelf_getshdr(scn, &sh))
|
||||
if (!gelf_getshdr(scn, &sh) || !sh.sh_entsize)
|
||||
return -EINVAL;
|
||||
|
||||
iter->strtabidx = sh.sh_link;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user