summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-11-07 12:15:17 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2015-11-07 12:15:17 -0800
commit99aaa9c64be5fe728975109c96ef297f5650883d (patch)
tree7a4338adaafb52fff8e4b3bb767665b9c343aef0
parent27eb427bdc0960ad64b72da03e3596c801e7a9e9 (diff)
parente2391a2dcaca41c6de0fbc25329969fc7142f20d (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/livepatching
Pull livepatching fix from Jiri Kosina: "A fix for a kernel oops in case CONFIG_DEBUG_SET_MODULE_RONX is unset (as in such case it's possible for module struct to share a page with executable text, which is currently not being handled with grace) from Josh Poimboeuf" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/livepatching: livepatch: Fix crash with !CONFIG_DEBUG_SET_MODULE_RONX
-rw-r--r--arch/x86/kernel/livepatch.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/arch/x86/kernel/livepatch.c b/arch/x86/kernel/livepatch.c
index ff3c3101d003..d1d35ccffed3 100644
--- a/arch/x86/kernel/livepatch.c
+++ b/arch/x86/kernel/livepatch.c
@@ -42,7 +42,6 @@ int klp_write_module_reloc(struct module *mod, unsigned long type,
bool readonly;
unsigned long val;
unsigned long core = (unsigned long)mod->module_core;
- unsigned long core_ro_size = mod->core_ro_size;
unsigned long core_size = mod->core_size;
switch (type) {
@@ -70,10 +69,12 @@ int klp_write_module_reloc(struct module *mod, unsigned long type,
/* loc does not point to any symbol inside the module */
return -EINVAL;
- if (loc < core + core_ro_size)
+ readonly = false;
+
+#ifdef CONFIG_DEBUG_SET_MODULE_RONX
+ if (loc < core + mod->core_ro_size)
readonly = true;
- else
- readonly = false;
+#endif
/* determine if the relocation spans a page boundary */
numpages = ((loc & PAGE_MASK) == ((loc + size) & PAGE_MASK)) ? 1 : 2;