Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99aaa9c6 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents 27eb427b e2391a2d
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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,11 +69,13 @@ 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 = true;
	else
	readonly = false;

#ifdef CONFIG_DEBUG_SET_MODULE_RONX
	if (loc < core + mod->core_ro_size)
		readonly = true;
#endif

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