Not all mod_mem_type will be included for kernel modules. E.g. in the
following module case:
(gdb) p lm->symtable[0]
$1 = (struct syment *) 0x4dcbad0
(gdb) p lm->symtable[1]
$2 = (struct syment *) 0x4dcbb70
(gdb) p lm->symtable[2]
$3 = (struct syment *) 0x4dcbc10
(gdb) p lm->symtable[3]
$4 = (struct syment *) 0x0
(gdb) p lm->symtable[4]
$5 = (struct syment *) 0x4dcbcb0
(gdb) p lm->symtable[5]
$6 = (struct syment *) 0x4dcbd00
(gdb) p lm->symtable[6]
$7 = (struct syment *) 0x0
(gdb) p lm->symtable[7]
$8 = (struct syment *) 0x4dcbb48
mod_mem MOD_RO_AFTER_INIT(3) and MOD_INIT_RODATA(6) is not exist, which should
be skipped, otherwise a segfault will happen.
Fixes: 7750e61fdb2a ("Support module memory layout change on Linux 6.4")
Signed-off-by: Tao Liu <ltao(a)redhat.com>
Reported-by: Naveen Chaudhary <naveenchaudhary2010(a)hotmail.com>
---
v1 -> v2: Keep the same code style as other similar iteration/checking cases.
---
symbols.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/symbols.c b/symbols.c
index cbc9ed1..b7627a8 100644
--- a/symbols.c
+++ b/symbols.c
@@ -5577,6 +5577,9 @@ value_search_module_6_4(ulong value, ulong *offset)
continue;
for_each_mod_mem_type(t) {
+ if (!lm->symtable[t])
+ continue;
+
sp = lm->symtable[t];
sp_end = lm->symend[t];
--
2.40.1