Skip to content

Commit 99aaa9c

Browse files
committed
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
2 parents 27eb427 + e2391a2 commit 99aaa9c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

arch/x86/kernel/livepatch.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ int klp_write_module_reloc(struct module *mod, unsigned long type,
4242
bool readonly;
4343
unsigned long val;
4444
unsigned long core = (unsigned long)mod->module_core;
45-
unsigned long core_ro_size = mod->core_ro_size;
4645
unsigned long core_size = mod->core_size;
4746

4847
switch (type) {
@@ -70,10 +69,12 @@ int klp_write_module_reloc(struct module *mod, unsigned long type,
7069
/* loc does not point to any symbol inside the module */
7170
return -EINVAL;
7271

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)
7476
readonly = true;
75-
else
76-
readonly = false;
77+
#endif
7778

7879
/* determine if the relocation spans a page boundary */
7980
numpages = ((loc & PAGE_MASK) == ((loc + size) & PAGE_MASK)) ? 1 : 2;

0 commit comments

Comments
 (0)