modpost: fix off by one in is_executable_section()
authorDan Carpenter <dan.carpenter@linaro.org>
Thu, 8 Jun 2023 08:23:40 +0000 (11:23 +0300)
committerMasahiro Yamada <masahiroy@kernel.org>
Thu, 8 Jun 2023 13:50:04 +0000 (22:50 +0900)
The > comparison should be >= to prevent an out of bounds array
access.

Fixes: 52dc0595d540 ("modpost: handle relocations mismatch in __ex_table.")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/mod/modpost.c

index 3ea5eb2b1029bed1df90f7112c470dd186624cad..8decf04633bc0616420dfbc8300b443e73295c37 100644 (file)
@@ -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;