Skip to content

Commit

Permalink
modpost: fix off by one in is_executable_section()
Browse files Browse the repository at this point in the history
The > comparison should be >= to prevent an out of bounds array
access.

Fixes: 52dc059 ("modpost: handle relocations mismatch in __ex_table.")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
  • Loading branch information
Dan Carpenter authored and Masahiro Yamada committed Jun 8, 2023
1 parent 98d7c75 commit 3a3f1e5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/mod/modpost.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ static Elf_Sym *find_tosym(struct elf_info *elf, Elf_Addr addr, Elf_Sym *sym)

static bool is_executable_section(struct elf_info *elf, unsigned int secndx)
{
if (secndx > elf->num_sections)
if (secndx >= elf->num_sections)
return false;

return (elf->sechdrs[secndx].sh_flags & SHF_EXECINSTR) != 0;
Expand Down

0 comments on commit 3a3f1e5

Please sign in to comment.