summaryrefslogtreecommitdiff
path: root/scripts/mod
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@linaro.org>2023-06-08 11:23:40 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-07-19 17:21:42 +0300
commitdd872d5576cc94528f427c7264c2c438928cc6d2 (patch)
treee137e536a52786a6d45c47c0ec018b17cf5afe30 /scripts/mod
parent64c358c9abae443e9e8745884006668a8ad92c93 (diff)
downloadlinux-dd872d5576cc94528f427c7264c2c438928cc6d2.tar.xz
modpost: fix off by one in is_executable_section()
[ 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>
Diffstat (limited to 'scripts/mod')
-rw-r--r--scripts/mod/modpost.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 9e370e77f52d..e6be7fc2625f 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1297,7 +1297,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);