From 85a055665efd3bc9d9ccbcc79e08bc361e4037b7 Mon Sep 17 00:00:00 2001 From: Jessica Yu Date: Wed, 17 Feb 2016 13:09:20 -0800 Subject: [PATCH] kmod: core: use new module core_layout struct Commit 7523e4dc5057 upstream ("module: use a structure to encapsulate layout") uses a new field to access module memory. Account for this change and ensure backwards compatibility with kernel versions < 4.5 --- kmod/core/core.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/kmod/core/core.c b/kmod/core/core.c index 2d52607..cb6c18c 100644 --- a/kmod/core/core.c +++ b/kmod/core/core.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include "kpatch.h" @@ -583,8 +584,13 @@ static int kpatch_write_relocations(struct kpatch_module *kpmod, int ret, size, readonly = 0, numpages; struct kpatch_dynrela *dynrela; u64 loc, val; - unsigned long core = (unsigned long)kpmod->mod->module_core; - unsigned long core_size = kpmod->mod->core_size; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) + unsigned long core = (unsigned long)kpmod->mod->core_layout.base; + unsigned long core_size = kpmod->mod->core_layout.size; +#else + unsigned long core = (unsigned long)kpmod->mod->module_core; + unsigned long core_size = kpmod->mod->core_size; +#endif unsigned long src; list_for_each_entry(dynrela, &object->dynrelas, list) { @@ -645,7 +651,11 @@ static int kpatch_write_relocations(struct kpatch_module *kpmod, } #ifdef CONFIG_DEBUG_SET_MODULE_RONX - if (loc < core + kpmod->mod->core_ro_size) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) + if (loc < core + kpmod->mod->core_layout.ro_size) +#else + if (loc < core + kpmod->mod->core_ro_size) +#endif readonly = 1; #endif