From: yangshiguang <yangshiguang(a)xiaomi.com>
Support module memory layout change on linux 6.18
by kernel commit b4760ff ("module: deprecate usage of
*_gpl sections in module loader")[1].
Without the patch, crash cannot start a session
with an error message like this:
crash: invalid structure member offset: module_num_gpl_syms
FILE: kernel.c LINE: 3834 FUNCTION: module_init()
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?...
Signed-off-by: yangshiguang <yangshiguang(a)xiaomi.com>
---
kernel.c | 5 +++--
symbols.c | 18 ++++++++++++++----
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/kernel.c b/kernel.c
index 8781d6a..786eb73 100644
--- a/kernel.c
+++ b/kernel.c
@@ -3830,8 +3830,9 @@ module_init(void)
nsyms = UINT(modbuf + OFFSET(module_nsyms));
break;
case KMOD_V2:
- nsyms = UINT(modbuf + OFFSET(module_num_syms)) +
- UINT(modbuf + OFFSET(module_num_gpl_syms));
+ nsyms = UINT(modbuf + OFFSET(module_num_syms));
+ if (VALID_MEMBER(module_num_gpl_syms))
+ nsyms += UINT(modbuf + OFFSET(module_num_gpl_syms));
break;
}
diff --git a/symbols.c b/symbols.c
index e6865ca..189fe3e 100644
--- a/symbols.c
+++ b/symbols.c
@@ -1976,9 +1976,14 @@ store_module_symbols_6_4(ulong total, int mods_installed)
"module buffer", FAULT_ON_ERROR);
syms = ULONG(modbuf + OFFSET(module_syms));
- gpl_syms = ULONG(modbuf + OFFSET(module_gpl_syms));
nsyms = UINT(modbuf + OFFSET(module_num_syms));
- ngplsyms = UINT(modbuf + OFFSET(module_num_gpl_syms));
+ if (VALID_MEMBER(module_gpl_syms) &&
VALID_MEMBER(module_num_gpl_syms)) {
+ gpl_syms = ULONG(modbuf + OFFSET(module_gpl_syms));
+ ngplsyms = UINT(modbuf + OFFSET(module_num_gpl_syms));
+ } else {
+ gpl_syms = 0;
+ ngplsyms = 0;
+ }
nksyms = UINT(modbuf + OFFSET(module_num_symtab));
@@ -2336,9 +2341,14 @@ store_module_symbols_v2(ulong total, int mods_installed)
"module buffer", FAULT_ON_ERROR);
syms = ULONG(modbuf + OFFSET(module_syms));
- gpl_syms = ULONG(modbuf + OFFSET(module_gpl_syms));
nsyms = UINT(modbuf + OFFSET(module_num_syms));
- ngplsyms = UINT(modbuf + OFFSET(module_num_gpl_syms));
+ if (VALID_MEMBER(module_gpl_syms) &&
VALID_MEMBER(module_num_gpl_syms)) {
+ gpl_syms = ULONG(modbuf + OFFSET(module_gpl_syms));
+ ngplsyms = UINT(modbuf + OFFSET(module_num_gpl_syms));
+ } else {
+ gpl_syms = 0;
+ ngplsyms = 0;
+ }
if (THIS_KERNEL_VERSION >= LINUX(2,6,27)) {
nksyms = UINT(modbuf + OFFSET(module_num_symtab));
--
2.43.0
--
Crash-utility mailing list -- devel(a)lists.crash-utility.osci.io
To unsubscribe send an email to devel-leave(a)lists.crash-utility.osci.io
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines:
https://github.com/crash-utility/crash/wiki