From: Greg Kroah-Hartman Date: Mon, 23 May 2022 15:27:11 +0000 (+0200) Subject: 5.10-stable patches X-Git-Tag: v4.9.316~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e09142539ac0ed5448df059753ec8b8577ce8156;p=thirdparty%2Fkernel%2Fstable-queue.git 5.10-stable patches added patches: module-treat-exit-sections-the-same-as-init-sections-when-config_module_unload.patch --- diff --git a/queue-5.10/module-treat-exit-sections-the-same-as-init-sections-when-config_module_unload.patch b/queue-5.10/module-treat-exit-sections-the-same-as-init-sections-when-config_module_unload.patch new file mode 100644 index 00000000000..2bbe00bacc4 --- /dev/null +++ b/queue-5.10/module-treat-exit-sections-the-same-as-init-sections-when-config_module_unload.patch @@ -0,0 +1,78 @@ +From 33121347fb1c359bd6e3e680b9f2c6ced5734a81 Mon Sep 17 00:00:00 2001 +From: Jessica Yu +Date: Tue, 23 Mar 2021 13:15:41 +0100 +Subject: module: treat exit sections the same as init sections when !CONFIG_MODULE_UNLOAD + +From: Jessica Yu + +commit 33121347fb1c359bd6e3e680b9f2c6ced5734a81 upstream. + +Dynamic code patching (alternatives, jump_label and static_call) can +have sites in __exit code, even it __exit is never executed. Therefore +__exit must be present at runtime, at least for as long as __init code +is. + +Additionally, for jump_label and static_call, the __exit sites must also +identify as within_module_init(), such that the infrastructure is aware +to never touch them after module init -- alternatives are only ran once +at init and hence don't have this particular constraint. + +By making __exit identify as __init for MODULE_UNLOAD, the above is +satisfied. + +So, when !CONFIG_MODULE_UNLOAD, the section ordering should look like the +following, with the .exit sections moved to the init region of the module. + +Core section allocation order: + .text + .rodata + __ksymtab_gpl + __ksymtab_strings + .note.* sections + .bss + .data + .gnu.linkonce.this_module + Init section allocation order: + .init.text + .exit.text + .symtab + .strtab + +[jeyu: thanks to Peter Zijlstra for most of changelog] + +Link: https://lore.kernel.org/lkml/YFiuphGw0RKehWsQ@gunter/ +Link: https://lore.kernel.org/r/20210323142756.11443-1-jeyu@kernel.org +Acked-by: Peter Zijlstra (Intel) +Signed-off-by: Jessica Yu +Cc: Joerg Vehlow +Signed-off-by: Greg Kroah-Hartman +--- + kernel/module.c | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +--- a/kernel/module.c ++++ b/kernel/module.c +@@ -2861,7 +2861,11 @@ void * __weak module_alloc(unsigned long + + bool __weak module_init_section(const char *name) + { ++#ifndef CONFIG_MODULE_UNLOAD ++ return strstarts(name, ".init") || module_exit_section(name); ++#else + return strstarts(name, ".init"); ++#endif + } + + bool __weak module_exit_section(const char *name) +@@ -3171,11 +3175,6 @@ static int rewrite_section_headers(struc + temporary image. */ + shdr->sh_addr = (size_t)info->hdr + shdr->sh_offset; + +-#ifndef CONFIG_MODULE_UNLOAD +- /* Don't load .exit sections */ +- if (module_exit_section(info->secstrings+shdr->sh_name)) +- shdr->sh_flags &= ~(unsigned long)SHF_ALLOC; +-#endif + } + + /* Track but don't keep modinfo and version sections. */ diff --git a/queue-5.10/series b/queue-5.10/series index 8366a5c6215..896f08b8b3c 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -90,5 +90,6 @@ net-atlantic-verify-hw_head_-lies-within-tx-buffer-r.patch arm64-enable-repeat-tlbi-workaround-on-kryo4xx-gold-.patch input-ili210x-fix-reset-timing.patch dt-bindings-pinctrl-aspeed-g6-remove-fwqspid-group.patch +module-treat-exit-sections-the-same-as-init-sections-when-config_module_unload.patch i2c-mt7621-fix-missing-clk_disable_unprepare-on-erro.patch afs-fix-afs_getattr-to-refetch-file-status-if-callba.patch