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@redhat.com>
Reported-by: Naveen Chaudhary <naveenchaudhary2010@hotmail.com>
---
symbols.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/symbols.c b/symbols.c
index cbc9ed1..27e55c6 100644
--- a/symbols.c
+++ b/symbols.c
@@ -5580,7 +5580,7 @@ value_search_module_6_4(ulong value, ulong *offset)
sp = lm->symtable[t];
sp_end = lm->symend[t];
- if (value < sp->value || value > sp_end->value)
+ if (!sp || value < sp->value || value > sp_end->value)
continue;
splast = NULL;
--
2.40.1