mirror of https://github.com/dynup/kpatch
use livepatch 4.5 features in Ubuntu Xenial kernel
Some features were backported into the 4.4 kernel which change the fields of the livepatch structures. Ensure we can work with either v4.5 or greater, or Ubuntu 4.4.0-7 or greater.
This commit is contained in:
parent
254e8bbe8d
commit
eb55adc52d
|
@ -46,8 +46,13 @@
|
|||
#include <linux/string.h>
|
||||
#include <asm/stacktrace.h>
|
||||
#include <asm/cacheflush.h>
|
||||
#include <generated/utsrelease.h>
|
||||
#include "kpatch.h"
|
||||
|
||||
#ifndef UTS_UBUNTU_RELEASE_ABI
|
||||
#define UTS_UBUNTU_RELEASE_ABI 0
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_FUNCTION_TRACER) || \
|
||||
!defined(CONFIG_HAVE_FENTRY) || \
|
||||
!defined(CONFIG_MODULES) || \
|
||||
|
@ -676,7 +681,10 @@ static int kpatch_write_relocations(struct kpatch_module *kpmod,
|
|||
int ret, size, readonly = 0, numpages;
|
||||
struct kpatch_dynrela *dynrela;
|
||||
u64 loc, val;
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
|
||||
#if (( LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) ) || \
|
||||
( LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) && \
|
||||
UTS_UBUNTU_RELEASE_ABI >= 7 ) \
|
||||
)
|
||||
unsigned long core = (unsigned long)kpmod->mod->core_layout.base;
|
||||
unsigned long core_size = kpmod->mod->core_layout.size;
|
||||
#else
|
||||
|
@ -746,7 +754,10 @@ static int kpatch_write_relocations(struct kpatch_module *kpmod,
|
|||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG_SET_MODULE_RONX
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
|
||||
#if (( LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) ) || \
|
||||
( LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) && \
|
||||
UTS_UBUNTU_RELEASE_ABI >= 7 ) \
|
||||
)
|
||||
if (loc < core + kpmod->mod->core_layout.ro_size)
|
||||
#else
|
||||
if (loc < core + kpmod->mod->core_ro_size)
|
||||
|
|
|
@ -25,11 +25,16 @@
|
|||
#include <linux/list.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/version.h>
|
||||
#include <generated/utsrelease.h>
|
||||
|
||||
#include <linux/livepatch.h>
|
||||
|
||||
#include "kpatch-patch.h"
|
||||
|
||||
#ifndef UTS_UBUNTU_RELEASE_ABI
|
||||
#define UTS_UBUNTU_RELEASE_ABI 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* There are quite a few similar structures at play in this file:
|
||||
* - livepatch.h structs prefixed with klp_*
|
||||
|
@ -238,7 +243,10 @@ static int __init patch_init(void)
|
|||
lfunc = &lfuncs[j];
|
||||
lfunc->old_name = func->kfunc->name;
|
||||
lfunc->new_func = (void *)func->kfunc->new_addr;
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
|
||||
#if (( LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) ) || \
|
||||
( LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) && \
|
||||
UTS_UBUNTU_RELEASE_ABI >= 7 ) \
|
||||
)
|
||||
lfunc->old_sympos = func->kfunc->sympos;
|
||||
#else
|
||||
lfunc->old_addr = func->kfunc->old_addr;
|
||||
|
@ -255,7 +263,10 @@ static int __init patch_init(void)
|
|||
list_for_each_entry(reloc, &object->relocs, list) {
|
||||
lreloc = &lrelocs[j];
|
||||
lreloc->loc = reloc->kdynrela->dest;
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
|
||||
#if (( LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) ) || \
|
||||
( LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) && \
|
||||
UTS_UBUNTU_RELEASE_ABI >= 7 ) \
|
||||
)
|
||||
lreloc->sympos = reloc->kdynrela->sympos;
|
||||
#else
|
||||
lreloc->val = reloc->kdynrela->src;
|
||||
|
|
Loading…
Reference in New Issue