On 1/5/25 15:51, Petr Pavlu wrote: > On 12/30/24 01:09, Marek Maślanka wrote: >> Hi Mike and others, >> >> I discovered that the patch "[v7,4/8] module: prepare to handle ROX allocations >> for text" has disrupted livepatch functionality. Specifically, this occurs when >> livepatch is prepared to patch a kernel module and when the livepatch module >> contains a "special" relocation section named >> ".klp.rela.<MODULE_NAME>.<SECTION_NAME>" to access local symbols. > > Thank you for the report. It is possible for me to reproduce the issue > on my system. An annoying part is to create the > .klp.rela.<objname>.<secname> data, for which I eventually used one > floating variant of klp-convert [1]. To hit the problem, <objname> must > point to an object that is different from vmlinux. Such relocations are > processed by the livepatch code later than regular module relocations, > as you pointed out after mod->rw_copy is already reset. > > I think the bug should be addressed in principle by Mike's recently > posted rework of the feature [2] but unfortunately, its current version > makes my system also unbootable [3]. A simpler fix could be: diff --git a/include/linux/module.h b/include/linux/module.h index 94acbacdcdf1..b3a643435357 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -773,7 +773,8 @@ void *__module_writable_address(struct module *mod, void *loc); static inline void *module_writable_address(struct module *mod, void *loc) { - if (!IS_ENABLED(CONFIG_ARCH_HAS_EXECMEM_ROX) || !mod) + if (!IS_ENABLED(CONFIG_ARCH_HAS_EXECMEM_ROX) || !mod || + mod->state != MODULE_STATE_UNFORMED) return loc; return __module_writable_address(mod, loc); } Hm, is it expected that Mike's rework to drop rw_copy will make it into 6.13 or should I properly post this minimal fix for review? -- Thanks, Petr