aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/moduleloader.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2023-02-23 14:00:10 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2023-02-23 14:00:10 -0800
commit7dd86cf80127aeef8a447c81228a77f0f25cc211 (patch)
tree5edb72af92df06db74459a8e3da8b283d9dd757f /include/linux/moduleloader.h
parentMerge tag 'printk-for-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux (diff)
parentlivepatch,x86: Clear relocation targets on a module removal (diff)
downloadwireguard-linux-7dd86cf80127aeef8a447c81228a77f0f25cc211.tar.xz
wireguard-linux-7dd86cf80127aeef8a447c81228a77f0f25cc211.zip
Merge tag 'livepatching-for-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching
Pull livepatching updates from Petr Mladek: - Allow reloading a livepatched module by clearing livepatch-specific relocations in the livepatch module. Otherwise, the repeated load would fail on consistency checks. * tag 'livepatching-for-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching: livepatch,x86: Clear relocation targets on a module removal x86/module: remove unused code in __apply_relocate_add
Diffstat (limited to 'include/linux/moduleloader.h')
-rw-r--r--include/linux/moduleloader.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
index 7b4587a19189..03be088fb439 100644
--- a/include/linux/moduleloader.h
+++ b/include/linux/moduleloader.h
@@ -75,6 +75,23 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
unsigned int symindex,
unsigned int relsec,
struct module *mod);
+#ifdef CONFIG_LIVEPATCH
+/*
+ * Some architectures (namely x86_64 and ppc64) perform sanity checks when
+ * applying relocations. If a patched module gets unloaded and then later
+ * reloaded (and re-patched), klp re-applies relocations to the replacement
+ * function(s). Any leftover relocations from the previous loading of the
+ * patched module might trigger the sanity checks.
+ *
+ * To prevent that, when unloading a patched module, clear out any relocations
+ * that might trigger arch-specific sanity checks on a future module reload.
+ */
+void clear_relocate_add(Elf_Shdr *sechdrs,
+ const char *strtab,
+ unsigned int symindex,
+ unsigned int relsec,
+ struct module *me);
+#endif
#else
static inline int apply_relocate_add(Elf_Shdr *sechdrs,
const char *strtab,