Skip to content

Commit 110b1e0

Browse files
chleroypetrpavlu
authored andcommitted
module: Don't fail module loading when setting ro_after_init section RO failed
Once module init has succeded it is too late to cancel loading. If setting ro_after_init data section to read-only fails, all we can do is to inform the user through a warning. Reported-by: Thomas Gleixner <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Fixes: d1909c0 ("module: Don't ignore errors from set_memory_XX()") Signed-off-by: Christophe Leroy <[email protected]> Reviewed-by: Luis Chamberlain <[email protected]> Link: https://lore.kernel.org/r/d6c81f38da76092de8aacc8c93c4c65cb0fe48b8.1733427536.git.christophe.leroy@csgroup.eu Signed-off-by: Petr Pavlu <[email protected]>
1 parent 097fd00 commit 110b1e0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kernel/module/main.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2955,7 +2955,10 @@ static noinline int do_init_module(struct module *mod)
29552955
#endif
29562956
ret = module_enable_rodata_ro_after_init(mod);
29572957
if (ret)
2958-
goto fail_mutex_unlock;
2958+
pr_warn("%s: module_enable_rodata_ro_after_init() returned %d, "
2959+
"ro_after_init data might still be writable\n",
2960+
mod->name, ret);
2961+
29592962
mod_tree_remove_init(mod);
29602963
module_arch_freeing_init(mod);
29612964
for_class_mod_mem_type(type, init) {
@@ -2994,8 +2997,6 @@ static noinline int do_init_module(struct module *mod)
29942997

29952998
return 0;
29962999

2997-
fail_mutex_unlock:
2998-
mutex_unlock(&module_mutex);
29993000
fail_free_freeinit:
30003001
kfree(freeinit);
30013002
fail:

0 commit comments

Comments
 (0)