diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-11-07 15:15:17 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-11-07 15:15:17 -0500 |
| commit | 99aaa9c64be5fe728975109c96ef297f5650883d (patch) | |
| tree | 7a4338adaafb52fff8e4b3bb767665b9c343aef0 | |
| parent | 27eb427bdc0960ad64b72da03e3596c801e7a9e9 (diff) | |
| parent | e2391a2dcaca41c6de0fbc25329969fc7142f20d (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.c | 9 |
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, | |||
| 42 | bool readonly; | 42 | bool readonly; |
| 43 | unsigned long val; | 43 | unsigned long val; |
| 44 | unsigned long core = (unsigned long)mod->module_core; | 44 | unsigned long core = (unsigned long)mod->module_core; |
| 45 | unsigned long core_ro_size = mod->core_ro_size; | ||
| 46 | unsigned long core_size = mod->core_size; | 45 | unsigned long core_size = mod->core_size; |
| 47 | 46 | ||
| 48 | switch (type) { | 47 | switch (type) { |
| @@ -70,10 +69,12 @@ int klp_write_module_reloc(struct module *mod, unsigned long type, | |||
| 70 | /* loc does not point to any symbol inside the module */ | 69 | /* loc does not point to any symbol inside the module */ |
| 71 | return -EINVAL; | 70 | return -EINVAL; |
| 72 | 71 | ||
| 73 | if (loc < core + core_ro_size) | 72 | readonly = false; |
| 73 | |||
| 74 | #ifdef CONFIG_DEBUG_SET_MODULE_RONX | ||
| 75 | if (loc < core + mod->core_ro_size) | ||
| 74 | readonly = true; | 76 | readonly = true; |
| 75 | else | 77 | #endif |
| 76 | readonly = false; | ||
| 77 | 78 | ||
| 78 | /* determine if the relocation spans a page boundary */ | 79 | /* determine if the relocation spans a page boundary */ |
| 79 | numpages = ((loc & PAGE_MASK) == ((loc + size) & PAGE_MASK)) ? 1 : 2; | 80 | numpages = ((loc & PAGE_MASK) == ((loc + size) & PAGE_MASK)) ? 1 : 2; |
