mirror of https://github.com/dynup/kpatch
Merge pull request #637 from arges/636
kpatch and patch module builds fail on Ubuntu 16.04 #636
This commit is contained in:
commit
e9fc979712
|
@ -46,8 +46,13 @@
|
||||||
#include <linux/string.h>
|
#include <linux/string.h>
|
||||||
#include <asm/stacktrace.h>
|
#include <asm/stacktrace.h>
|
||||||
#include <asm/cacheflush.h>
|
#include <asm/cacheflush.h>
|
||||||
|
#include <generated/utsrelease.h>
|
||||||
#include "kpatch.h"
|
#include "kpatch.h"
|
||||||
|
|
||||||
|
#ifndef UTS_UBUNTU_RELEASE_ABI
|
||||||
|
#define UTS_UBUNTU_RELEASE_ABI 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(CONFIG_FUNCTION_TRACER) || \
|
#if !defined(CONFIG_FUNCTION_TRACER) || \
|
||||||
!defined(CONFIG_HAVE_FENTRY) || \
|
!defined(CONFIG_HAVE_FENTRY) || \
|
||||||
!defined(CONFIG_MODULES) || \
|
!defined(CONFIG_MODULES) || \
|
||||||
|
@ -632,7 +637,10 @@ static int kpatch_write_relocations(struct kpatch_module *kpmod,
|
||||||
int ret, size, readonly = 0, numpages;
|
int ret, size, readonly = 0, numpages;
|
||||||
struct kpatch_dynrela *dynrela;
|
struct kpatch_dynrela *dynrela;
|
||||||
u64 loc, val;
|
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 = (unsigned long)kpmod->mod->core_layout.base;
|
||||||
unsigned long core_size = kpmod->mod->core_layout.size;
|
unsigned long core_size = kpmod->mod->core_layout.size;
|
||||||
#else
|
#else
|
||||||
|
@ -702,7 +710,10 @@ static int kpatch_write_relocations(struct kpatch_module *kpmod,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_SET_MODULE_RONX
|
#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)
|
if (loc < core + kpmod->mod->core_layout.ro_size)
|
||||||
#else
|
#else
|
||||||
if (loc < core + kpmod->mod->core_ro_size)
|
if (loc < core + kpmod->mod->core_ro_size)
|
||||||
|
|
|
@ -25,11 +25,16 @@
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/version.h>
|
#include <linux/version.h>
|
||||||
|
#include <generated/utsrelease.h>
|
||||||
|
|
||||||
#include <linux/livepatch.h>
|
#include <linux/livepatch.h>
|
||||||
|
|
||||||
#include "kpatch-patch.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:
|
* There are quite a few similar structures at play in this file:
|
||||||
* - livepatch.h structs prefixed with klp_*
|
* - livepatch.h structs prefixed with klp_*
|
||||||
|
@ -238,7 +243,10 @@ static int __init patch_init(void)
|
||||||
lfunc = &lfuncs[j];
|
lfunc = &lfuncs[j];
|
||||||
lfunc->old_name = func->kfunc->name;
|
lfunc->old_name = func->kfunc->name;
|
||||||
lfunc->new_func = (void *)func->kfunc->new_addr;
|
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;
|
lfunc->old_sympos = func->kfunc->sympos;
|
||||||
#else
|
#else
|
||||||
lfunc->old_addr = func->kfunc->old_addr;
|
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) {
|
list_for_each_entry(reloc, &object->relocs, list) {
|
||||||
lreloc = &lrelocs[j];
|
lreloc = &lrelocs[j];
|
||||||
lreloc->loc = reloc->kdynrela->dest;
|
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;
|
lreloc->sympos = reloc->kdynrela->sympos;
|
||||||
#else
|
#else
|
||||||
lreloc->val = reloc->kdynrela->src;
|
lreloc->val = reloc->kdynrela->src;
|
||||||
|
|
|
@ -602,6 +602,14 @@ echo "Building patch module: kpatch-$PATCHNAME.ko"
|
||||||
cp "$OBJDIR/.config" "$SRCDIR"
|
cp "$OBJDIR/.config" "$SRCDIR"
|
||||||
cd "$SRCDIR"
|
cd "$SRCDIR"
|
||||||
make prepare >> "$LOGFILE" 2>&1 || die
|
make prepare >> "$LOGFILE" 2>&1 || die
|
||||||
|
|
||||||
|
if [[ $DISTRO == ubuntu ]]; then
|
||||||
|
# UBUNTU: add UTS_UBUNTU_RELEASE_ABI to utsrelease.h after regenerating it
|
||||||
|
UBUNTU_ABI=${ARCHVERSION#*-}
|
||||||
|
UBUNTU_ABI=${UBUNTU_ABI%-*}
|
||||||
|
echo "#define UTS_UBUNTU_RELEASE_ABI "$UBUNTU_ABI"" >> "$SRCDIR"/include/generated/utsrelease.h
|
||||||
|
fi
|
||||||
|
|
||||||
cd "$TEMPDIR/output"
|
cd "$TEMPDIR/output"
|
||||||
ld -r -o ../patch/output.o $(find . -name "*.o") >> "$LOGFILE" 2>&1 || die
|
ld -r -o ../patch/output.o $(find . -name "*.o") >> "$LOGFILE" 2>&1 || die
|
||||||
md5sum ../patch/output.o | awk '{printf "%s\0", $1}' > checksum.tmp || die
|
md5sum ../patch/output.o | awk '{printf "%s\0", $1}' > checksum.tmp || die
|
||||||
|
|
Loading…
Reference in New Issue