modpost: handle relocations mismatch in __ex_table.
[ Ancient code warning. - dan ]
Hello Quentin Casasnovas,
The patch 52dc0595d540: "modpost: handle relocations mismatch in __ex_table." from Apr 13, 2015, leads to the following Smatch static checker warning:
./scripts/mod/modpost.c:1154 is_executable_section() warn: array off by one? 'elf->sechdrs[secndx]'
./scripts/mod/modpost.c
1149 static bool is_executable_section(struct elf_info *elf, unsigned int secndx)
1150 {
1151 if (secndx > elf->num_sections)
^^^^^^^^^^^^^^^^^^^^^^^^^^I'm not positive, but I think this should be >=.
1152 return false;
1153
--> 1154 return (elf->sechdrs[secndx].sh_flags & SHF_EXECINSTR) != 0;
^^^^^^out of bounds read.
1155 }
regards,
dan carpenter
Quoted 12 lines · Dan Carpenter
[ Ancient code warning. - dan ]
Hello Quentin Casasnovas,
The patch
52dc0595d540: "modpost: handle relocations mismatch in__ex_table." from Apr 13, 2015, leads to the following Smatch static checker warning:./scripts/mod/modpost.c:1154 is_executable_section() warn: array off by one? 'elf->sechdrs[secndx]'
Quoted 6 lines
./scripts/mod/modpost.c1149 static bool is_executable_section(struct elf_info *elf, unsigned int secndx) 1150 { 1151 if (secndx > elf->num_sections) ^^^^^^^^^^^^^^^^^^^^^^^^^^I'm not positive, but I think this should be >=.
Ah, right. This is a bug, and your fix is correct.
Quoted 11 lines
1152 return false; 1153 --> 1154 return (elf->sechdrs[secndx].sh_flags & SHF_EXECINSTR) != 0; ^^^^^^out of bounds read.
1155 }regards,
dan carpenter
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 16 lines · Dan Carpenter
[ Ancient code warning. - dan ]
Hello Quentin Casasnovas,
The patch
52dc0595d540: "modpost: handle relocations mismatch in__ex_table." from Apr 13, 2015, leads to the following Smatch static checker warning:./scripts/mod/modpost.c:1154 is_executable_section() warn: array off by one? 'elf->sechdrs[secndx]'
./scripts/mod/modpost.c1149 static bool is_executable_section(struct elf_info *elf, unsigned int secndx) 1150 { 1151 if (secndx > elf->num_sections) ^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 8 lines
I'm not positive, but I think this should be >=.
1152 return false; 1153 --> 1154 return (elf->sechdrs[secndx].sh_flags & SHF_EXECINSTR) != 0; ^^^^^^out of bounds read.
Oops, that is embarassing - thanks for catching that!
Have you already prepared a fix or shall I send it over?
Q
Quoted 4 lines
1155 }regards,
dan carpenter
Quoted 3 lines · Quentin Casasnovas
Have you already prepared a fix or shall I send it over?
I sent the fix on Thursday and Masahiro Yamada already applied it. I Cc'd you but probably you're like me and respond to email in the order it's recieved?
https://lore.kernel.org/all/CAK7LNATWmtiQdtvGLYL5b0Pyg4Bnmj0_Hn8xtWLzMJ_1oxkThA@mail.gmail.com/
regards,
dan carpenter
Quoted 9 lines · Dan Carpenter
Quoted 3 lines · Quentin Casasnovas
Have you already prepared a fix or shall I send it over?
I sent the fix on Thursday and Masahiro Yamada already applied it. I Cc'd you but probably you're like me and respond to email in the order it's recieved?
Indeed, I just cleaned up my mailbox and saw your patch. Thanks for the fix!
Q