]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jul 2023 06:37:18 +0000 (08:37 +0200)
[ Upstream commit 3a3f1e573a105328a2cca45a7cfbebabbf5e3192 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
scripts/mod/modpost.c

index 75d76b8f50302323c80f0677ef91708e0d5d8291..53e276bb24acd2d3c91202c5b7229bb9ff0053fc 100644 (file)
@@ -1633,7 +1633,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
 
 static int is_executable_section(struct elf_info* elf, unsigned int section_index)
 {
-       if (section_index > elf->num_sections)
+       if (section_index >= elf->num_sections)
                fatal("section_index is outside elf->num_sections!\n");
 
        return ((elf->sechdrs[section_index].sh_flags & SHF_EXECINSTR) == SHF_EXECINSTR);