Hi,
A dumpfile may contain readable struct module objects while a missing
or corrupt list node prevents crash from walking the global modules
list. The current behavior sets NO_MODULE_ACCESS, so "mod -S" cannot
load symbols for any of the remaining modules.
The module_kset list provides an independent path to the same loaded
module objects on KMOD_V2 kernels. The patch uses it only after normal
module access fails and only for dumpfiles. Live kernels keep using the
existing path, avoiding addresses that may become stale.
The recovery reuses do_list() and the existing hash queue. It accepts
the readable prefix of a damaged module_kset list, which is useful for
incomplete dumps. Entries with module_kobject.mod == NULL are skipped.
They are sysfs objects for built-in modules, where THIS_MODULE is NULL.
For non-NULL entries, the embedded module.mkobj backlink is validated
before the struct module address is accepted.
Module symbol collection performs a second pass. The recovered
addresses are therefore kept in a local array and passed explicitly to
the symbol storage functions. This avoids adding persistent state to
kernel_table. Both the pre-6.4 layout and the module.mem layout added
in Linux 6.4 use the same recovered list. If no module is recovered,
the existing NO_MODULE_ACCESS behavior is preserved.
Tested with:
- ARM64 build: make target=ARM64 -j40
- Complete Linux 6.18 sysrq dump: 278 module objects loaded without the
fallback path.
- Incomplete dump: 473 module_kset entries were scanned. The fallback
recovered 346 loaded modules, skipped 126 built-in objects and one
unreadable entry, and "mod -S" loaded the available module symbols.
Only the recovery result is reported by the new code. Its wording
distinguishes loaded modules from built-in kobjects and applies to both
the pre-6.4 and 6.4+ module memory layouts.
Comments are welcome.
wya (1):
kernel: recover modules from module_kset
defs.h | 7 ++-
kernel.c | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++----
symbols.c | 33 ++++++++--
3 files changed, 195 insertions(+), 20 deletions(-)
--
2.43.0