On 11/12/26 12:44 PM, Rui Yang wrote:
[snip]
> /*
> * Store the head of the kernel module list for future use.
> * Count the number of symbols defined by all modules in the system,
> @@ -3624,10 +3802,11 @@ get_dumpfile_regs(struct bt_info *bt, ulong *eip, ulong
*esp)
> void
> module_init(void)
> {
> - int i, c;
> + int i, c, recover;
> ulong size, mod, mod_next;
> uint nsyms;
> ulong total, numksyms;
> + ulong *module_addr_list;
> char *modbuf, *kallsymsbuf;
> ulong kallsyms_header;
> struct syment *sp, *sp_array[10];
> @@ -3647,6 +3826,9 @@ module_init(void)
> else
> error(WARNING, "cannot determine how modules are linked\n");
>
> + /* Build dump module data once, before any object files are loaded. */
> + recover = DUMPFILE() && (kt->flags & KMOD_V2) &&
> + !(kt->flags & KALLSYMS_V1) && !(kt->flags2 & KMOD_PAX);
> if (kt->flags & NO_MODULE_ACCESS || !(kt->flags &
(KMOD_V1|KMOD_V2))) {
> error(WARNING, "no kernel module access\n\n");
> kt->module_list = 0;
> @@ -3791,6 +3973,24 @@ module_init(void)
> }
>
> MEMBER_OFFSET_INIT(module_percpu, "module", "percpu");
> + /* The sanitizer handles core/init and module.mem, not PaX regions. */
> + if (kt->flags2 & KMOD_PAX)
> + recover = FALSE;
> + if (MEMBER_EXISTS("module", "mkobj"))
> + MEMBER_OFFSET_INIT(module_mkobj, "module", "mkobj");
> + if (STRUCT_EXISTS("module_kobject")) {
> + if (MEMBER_EXISTS("module_kobject", "kobj"))
> + MEMBER_OFFSET_INIT(module_kobject_kobj,
> + "module_kobject", "kobj");
> + if (MEMBER_EXISTS("module_kobject", "mod"))
> + MEMBER_OFFSET_INIT(module_kobject_mod,
> + "module_kobject", "mod");
> + }
> + if (STRUCT_EXISTS("kset") && MEMBER_EXISTS("kset",
"list"))
> + MEMBER_OFFSET_INIT(kset_list, "kset", "list");
> + if (STRUCT_EXISTS("kobject") &&
> + MEMBER_EXISTS("kobject", "entry"))
> + MEMBER_OFFSET_INIT(kobject_entry, "kobject", "entry");
The crash init path is heavy, I have a plan to cleanup it in the future. So let's
think
about it more, is the offset visited often enough to be put in the global offset table?
It seems better to not add extra offset for this case. That means you can get the
offset
in your local functions separately.
You may avoid extra crash options to enable the recovery, and handle the recovery in the
"mod" command
code, and do the recovery when NO_MODULE_ACCESS reason is a list corruption. For example
add a `mod -f`
etc.