Debian

Available patches from Ubuntu

To see Ubuntu differences wrt. to Debian, write down a grep-dctrl query identifying the packages you're interested in:
grep-dctrl -n -sPackage Sources.Debian
(e.g. -FPackage linux-ntfs or linux-ntfs)

Modified packages are listed below:

Debian ( Changelog | PTS | Bugs ) Ubuntu ( Changelog | txt | LP | Bugs ) | Diff from Ubuntu

Source: kpatch

kpatch (0.5.0-0ubuntu2) disco; urgency=medium * Import v0.6 pataches from unstable for v4.19/v5 compat. * Add more shellcheck fixes. -- Dimitri John Ledkov <xnox@ubuntu.com> Mon, 18 Feb 2019 09:39:39 +0100 kpatch (0.5.0-0ubuntu1) bionic; urgency=low * Upstream bump to 0.5.0 (LP: #1763065). * Drop patches that are present in the upstream release: - kpatch-build-works-without-kpatch-kmod.patch - kmod-core-fix-stacktrace_ops-address-function-protot.patch - create-diff-object-fix-WARN-_ONCE-detection-on-newer.patch - use-livepatch-4.5-kernel-features.patch * output-kernel-build-in-debug.patch was dropped to reduce build output. * These remaining patches have been updated to apply to the refreshed upstream: - kpatch-build-adjust-dirs.patch - use-debian-rules-for-ubuntu-builds.patch - ubuntu-kernel-variants.patch * The shellcheck linter is called during packaging, to verify the quality of the scripts used in the package. * List the Ubuntu Kernel Team as the package maintainer in the control file * kmod/core: fix stacktrace_ops 'address' function prototype for 4.6 (LP: #1665613, #1659581) -- Benjamin M Romer <benjamin.romer@canonical.com> Wed, 11 Apr 2018 21:41:51 -0400 kpatch (0.3.2-3ubuntu1) yakkety; urgency=low * Merge from Debian unstable. Remaining changes: - Add additional depends for building Ubuntu kernel - Ubuntu Specific Patches: - output-kernel-build-in-debug.patch - ubuntu-kernel-variants.patch - use-debian-rules-for-ubuntu-builds.patch - use-livepatch-4.5-kernel-features.patch - use-ubuntu-utsrelease-for-kpatch-build.patch - make dpks updates dir in post-dkms.sh script -- Chris J Arges <chris.j.arges@canonical.com> Tue, 16 Aug 2016 08:41:04 -0500

Modifications :
  1. Download patch test/integration/centos-7/module-kvm-fixup.patch

    --- 0.3.2-3.1/test/integration/centos-7/module-kvm-fixup.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/module-kvm-fixup.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,12 @@ +diff -Nupr src.orig/arch/x86/kvm/vmx.c src/arch/x86/kvm/vmx.c +--- src.orig/arch/x86/kvm/vmx.c 2017-09-22 15:27:20.853052676 -0400 ++++ src/arch/x86/kvm/vmx.c 2017-09-22 15:27:43.583146801 -0400 +@@ -10597,6 +10597,8 @@ static int vmx_check_intercept(struct kv + struct x86_instruction_info *info, + enum x86_intercept_stage stage) + { ++ if (!jiffies) ++ printk("kpatch vmx_check_intercept\n"); + return X86EMUL_CONTINUE; + } +
  2. Download patch test/integration/centos-7/cmdline-string.patch

    --- 0.3.2-3.1/test/integration/centos-7/cmdline-string.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/cmdline-string.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,12 @@ +diff -Nupr src.orig/fs/proc/cmdline.c src/fs/proc/cmdline.c +--- src.orig/fs/proc/cmdline.c 2017-09-22 15:27:21.698056175 -0400 ++++ src/fs/proc/cmdline.c 2017-09-22 15:27:22.955061380 -0400 +@@ -5,7 +5,7 @@ + + static int cmdline_proc_show(struct seq_file *m, void *v) + { +- seq_printf(m, "%s\n", saved_command_line); ++ seq_printf(m, "%s kpatch=1\n", saved_command_line); + return 0; + } +
  3. Download patch test/integration/centos-7/remote-setup

    --- 0.3.2-3.1/test/integration/centos-7/remote-setup 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/remote-setup 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,45 @@ +#!/bin/bash -x + +# install rpms on a Fedora 22 system to prepare it for kpatch integration tests + +set -o errexit + +[[ $UID != 0 ]] && sudo=sudo + +warn() { + echo "ERROR: $1" >&2 +} + +die() { + warn "$@" + exit 1 +} + +install_rpms() { + # crude workaround for a weird dnf bug where it fails to download + $sudo dnf install -y $* || $sudo dnf install -y $* +} + +install_rpms gcc elfutils elfutils-devel rpmdevtools pesign openssl numactl-devel wget patchutils + +$sudo dnf builddep -y kernel || $sudo dnf builddep -y kernel + +# install kernel debuginfo and devel RPMs for target kernel +kverrel=$(uname -r) +kverrel=${kverrel%.x86_64} +kver=${kverrel%%-*} +krel=${kverrel#*-} +install_rpms https://kojipkgs.fedoraproject.org/packages/kernel/$kver/$krel/x86_64/kernel-debuginfo-$kver-$krel.x86_64.rpm https://kojipkgs.fedoraproject.org/packages/kernel/$kver/$krel/x86_64/kernel-debuginfo-common-x86_64-$kver-$krel.x86_64.rpm https://kojipkgs.fedoraproject.org/packages/kernel/$kver/$krel/x86_64/kernel-devel-$kver-$krel.x86_64.rpm + +# install version of gcc which was used to build the target kernel +gccver=$(gcc --version |head -n1 |cut -d' ' -f3-) +kgccver=$(readelf -p .comment /usr/lib/debug/lib/modules/$(uname -r)/vmlinux |grep GCC: | tr -s ' ' | cut -d ' ' -f6-) +if [[ $gccver != $kgccver ]]; then + gver=$(echo $kgccver | awk '{print $1}') + grel=$(echo $kgccver | sed 's/.*-\(.*\))/\1/') + grel=$grel.$(rpm -q gcc |sed 's/.*\.\(.*\)\.x86_64/\1/') + install_rpms https://kojipkgs.fedoraproject.org/packages/gcc/$gver/$grel/x86_64/cpp-$gver-$grel.x86_64.rpm https://kojipkgs.fedoraproject.org/packages/gcc/$gver/$grel/x86_64/gcc-$gver-$grel.x86_64.rpm https://kojipkgs.fedoraproject.org/packages/gcc/$gver/$grel/x86_64/libgomp-$gver-$grel.x86_64.rpm +fi + +install_rpms ccache +ccache -M 5G
  4. Download patch test/integration/centos-7/multiple.test

    --- 0.3.2-3.1/test/integration/centos-7/multiple.test 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/multiple.test 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,45 @@ +#!/bin/bash + +SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))" +ROOTDIR="$(readlink -f $SCRIPTDIR/../../..)" +KPATCH="sudo $ROOTDIR/kpatch/kpatch" + +set -o errexit + +die() { + echo "ERROR: $@" >&2 + exit 1 +} + +ko_to_test() { + tmp=${1%.ko}-LOADED.test + echo ${tmp#kpatch-} +} + +# make sure any modules added here are disjoint +declare -a modules=(kpatch-cmdline-string.ko kpatch-meminfo-string.ko) + +for mod in "${modules[@]}"; do + testprog=$(ko_to_test $mod) + $SCRIPTDIR/$testprog && die "$SCRIPTDIR/$testprog succeeded before loading any modules" +done + +for mod in "${modules[@]}"; do + $KPATCH load $mod +done + +for mod in "${modules[@]}"; do + testprog=$(ko_to_test $mod) + $SCRIPTDIR/$testprog || die "$SCRIPTDIR/$testprog failed after loading modules" +done + +for mod in "${modules[@]}"; do + $KPATCH unload $mod +done + +for mod in "${modules[@]}"; do + testprog=$(ko_to_test $mod) + $SCRIPTDIR/$testprog && die "$SCRIPTDIR/$testprog succeeded after unloading modules" +done + +exit 0
  5. Download patch test/integration/centos-7/data-new-LOADED.test

    --- 0.3.2-3.1/test/integration/centos-7/data-new-LOADED.test 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/data-new-LOADED.test 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,3 @@ +#!/bin/bash + +grep "kpatch: 5" /proc/meminfo
  6. Download patch README.md
  7. Download patch kpatch-build/lookup.c
  8. Download patch test/integration/centos-7/shadow-newpid-LOADED.test

    --- 0.3.2-3.1/test/integration/centos-7/shadow-newpid-LOADED.test 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/shadow-newpid-LOADED.test 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,3 @@ +#!/bin/bash + +grep -q newpid: /proc/$$/status
  9. Download patch test/integration/centos-7/parainstructions-section.patch

    --- 0.3.2-3.1/test/integration/centos-7/parainstructions-section.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/parainstructions-section.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,11 @@ +diff -Nupr src.orig/fs/proc/generic.c src/fs/proc/generic.c +--- src.orig/fs/proc/generic.c 2017-09-22 15:27:21.698056175 -0400 ++++ src/fs/proc/generic.c 2017-09-22 15:27:48.190165879 -0400 +@@ -194,6 +194,7 @@ int proc_alloc_inum(unsigned int *inum) + unsigned int i; + int error; + ++ printk("kpatch-test: testing change to .parainstructions section\n"); + retry: + if (!ida_pre_get(&proc_inum_ida, GFP_KERNEL)) + return -ENOMEM;
  10. Download patch kpatch-build/create-diff-object.c
  11. Download patch kmod/patch/Makefile

    --- 0.3.2-3.1/kmod/patch/Makefile 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/kmod/patch/Makefile 2017-12-21 05:02:48.000000000 +0000 @@ -1,15 +1,23 @@ -KPATCH_NAME ?= patch KPATCH_BUILD ?= /lib/modules/$(shell uname -r)/build KPATCH_MAKE = $(MAKE) -C $(KPATCH_BUILD) M=$(PWD) +LDFLAGS += $(KPATCH_LDFLAGS) -obj-m += kpatch-$(KPATCH_NAME).o +# ppc64le kernel modules are expected to compile with the +# -mcmodel=large flag. This enables 64-bit relocations +# instead of a 32-bit offset from the TOC pointer. +PROCESSOR = $(shell uname -m) +ifeq ($(PROCESSOR), ppc64le) +KBUILD_CFLAGS_MODULE += -mcmodel=large +endif -kpatch-$(KPATCH_NAME)-objs += patch-hook.o kpatch.lds output.o +obj-m += $(KPATCH_NAME).o -all: kpatch-$(KPATCH_NAME).ko +$(KPATCH_NAME)-objs += patch-hook.o kpatch.lds output.o -kpatch-$(KPATCH_NAME).ko: - $(KPATCH_MAKE) kpatch-$(KPATCH_NAME).ko +all: $(KPATCH_NAME).ko + +$(KPATCH_NAME).ko: + $(KPATCH_MAKE) $(KPATCH_NAME).ko patch-hook.o: patch-hook.c kpatch-patch-hook.c livepatch-patch-hook.c $(KPATCH_MAKE) patch-hook.o
  12. Download patch debian/patches/kpatch-build-works-without-kpatch-kmod.patch

    --- 0.3.2-3.1/debian/patches/kpatch-build-works-without-kpatch-kmod.patch 2016-02-18 16:46:39.000000000 +0000 +++ 0.5.0-0ubuntu2/debian/patches/kpatch-build-works-without-kpatch-kmod.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -Description: only warn if kpatch module isn't available - kpatch-build checks if the kpatch module is installed properly. In cases where we build - livepatch modules this is not necessary. Turn these errors into warnings and let the user - proceed. -Author: Chris J Arges <chris.j.arges@canonical.com> -Last-Update: 2016-01-20 - ---- a/kpatch-build/kpatch-build -+++ b/kpatch-build/kpatch-build -@@ -109,7 +109,6 @@ - SYMVERSFILE="$(readlink -f /lib/modules/$ARCHVERSION/updates/dkms/kpatch.Module.symvers)" - else - warn "unable to find Module.symvers for kpatch core module" -- return 1 - fi - return - fi -@@ -340,7 +339,7 @@ - - find_dirs || die "can't find supporting tools" - --[[ -e "$SYMVERSFILE" ]] || die "can't find core module Module.symvers" -+[[ -e "$SYMVERSFILE" ]] || warn "can't find core module Module.symvers" - - - if [[ $SKIPGCCCHECK -eq 0 ]]; then
  13. Download patch kpatch-build/lookup.h

    --- 0.3.2-3.1/kpatch-build/lookup.h 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/kpatch-build/lookup.h 2017-12-21 05:02:48.000000000 +0000 @@ -9,12 +9,19 @@ struct lookup_result { unsigned long pos; }; -struct lookup_table *lookup_open(char *path); +struct sym_compare_type { + char *name; + int type; +}; + +struct lookup_table *lookup_open(char *obj_path, char *symvers_path, + char *hint, struct sym_compare_type *locals); void lookup_close(struct lookup_table *table); -int lookup_local_symbol(struct lookup_table *table, char *name, char *hint, +int lookup_local_symbol(struct lookup_table *table, char *name, struct lookup_result *result); int lookup_global_symbol(struct lookup_table *table, char *name, struct lookup_result *result); int lookup_is_exported_symbol(struct lookup_table *table, char *name); +char *lookup_exported_symbol_objname(struct lookup_table *table, char *name); #endif /* _LOOKUP_H_ */
  14. Download patch test/integration/centos-7/gcc-static-local-var-5.patch

    --- 0.3.2-3.1/test/integration/centos-7/gcc-static-local-var-5.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/gcc-static-local-var-5.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,45 @@ +diff -Nupr src.orig/kernel/audit.c src/kernel/audit.c +--- src.orig/kernel/audit.c 2017-09-22 15:27:21.602055778 -0400 ++++ src/kernel/audit.c 2017-09-22 15:27:34.429108894 -0400 +@@ -205,6 +205,12 @@ void audit_panic(const char *message) + } + } + ++void kpatch_audit_foo(void) ++{ ++ if (!jiffies) ++ printk("kpatch audit foo\n"); ++} ++ + static inline int audit_rate_check(void) + { + static unsigned long last_check = 0; +@@ -215,6 +221,7 @@ static inline int audit_rate_check(void) + unsigned long elapsed; + int retval = 0; + ++ kpatch_audit_foo(); + if (!audit_rate_limit) return 1; + + spin_lock_irqsave(&lock, flags); +@@ -234,6 +241,11 @@ static inline int audit_rate_check(void) + return retval; + } + ++noinline void kpatch_audit_check(void) ++{ ++ audit_rate_check(); ++} ++ + /** + * audit_log_lost - conditionally log lost audit message event + * @message: the message stating reason for lost audit message +@@ -282,6 +294,8 @@ static int audit_log_config_change(char + struct audit_buffer *ab; + int rc = 0; + ++ kpatch_audit_check(); ++ + ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE); + if (unlikely(!ab)) + return rc;
  15. Download patch test/integration/centos-7/data-read-mostly.patch

    --- 0.3.2-3.1/test/integration/centos-7/data-read-mostly.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/data-read-mostly.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,11 @@ +diff -Nupr src.orig/net/core/dev.c src/net/core/dev.c +--- src.orig/net/core/dev.c 2017-09-22 15:27:21.759056428 -0400 ++++ src/net/core/dev.c 2017-09-22 15:27:25.244070859 -0400 +@@ -4012,6 +4012,7 @@ ncls: + case RX_HANDLER_PASS: + break; + default: ++ printk("BUG!\n"); + BUG(); + } + }
  16. Download patch test/integration/f22/fixup-section.patch

    --- 0.3.2-3.1/test/integration/f22/fixup-section.patch 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/f22/fixup-section.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -Index: src/fs/readdir.c -=================================================================== ---- src.orig/fs/readdir.c -+++ src/fs/readdir.c -@@ -169,6 +169,8 @@ static int filldir(void * __buf, const c - goto efault; - } - dirent = buf->current_dir; -+ if (dirent->d_ino == 12345678) -+ printk("kpatch-test: testing .fixup section changes\n"); - if (__put_user(d_ino, &dirent->d_ino)) - goto efault; - if (__put_user(reclen, &dirent->d_reclen))
  17. Download patch test/integration/centos-7/warn-detect-FAIL.patch

    --- 0.3.2-3.1/test/integration/centos-7/warn-detect-FAIL.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/warn-detect-FAIL.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,8 @@ +diff -Nupr src.orig/arch/x86/kvm/x86.c src/arch/x86/kvm/x86.c +--- src.orig/arch/x86/kvm/x86.c 2017-09-22 15:27:20.852052672 -0400 ++++ src/arch/x86/kvm/x86.c 2017-09-22 15:27:55.489196104 -0400 +@@ -1,3 +1,4 @@ ++ + /* + * Kernel-based Virtual Machine driver for Linux + *
  18. Download patch test/integration/centos-7/new-globals.patch

    --- 0.3.2-3.1/test/integration/centos-7/new-globals.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/new-globals.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,34 @@ +diff -Nupr src.orig/fs/proc/cmdline.c src/fs/proc/cmdline.c +--- src.orig/fs/proc/cmdline.c 2017-09-22 15:27:21.698056175 -0400 ++++ src/fs/proc/cmdline.c 2017-09-22 15:27:47.028161067 -0400 +@@ -27,3 +27,10 @@ static int __init proc_cmdline_init(void + return 0; + } + module_init(proc_cmdline_init); ++ ++#include <linux/printk.h> ++void kpatch_print_message(void) ++{ ++ if (!jiffies) ++ printk("hello there!\n"); ++} +diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c +--- src.orig/fs/proc/meminfo.c 2017-09-22 15:27:21.699056179 -0400 ++++ src/fs/proc/meminfo.c 2017-09-22 15:27:47.029161071 -0400 +@@ -16,6 +16,8 @@ + #include <asm/pgtable.h> + #include "internal.h" + ++void kpatch_print_message(void); ++ + void __attribute__((weak)) arch_report_meminfo(struct seq_file *m) + { + } +@@ -53,6 +55,7 @@ static int meminfo_proc_show(struct seq_ + /* + * Tagged format, for easy grepping and expansion. + */ ++ kpatch_print_message(); + seq_printf(m, + "MemTotal: %8lu kB\n" + "MemFree: %8lu kB\n"
  19. Download patch test/integration/centos-7/bug-table-section.patch

    --- 0.3.2-3.1/test/integration/centos-7/bug-table-section.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/bug-table-section.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,12 @@ +diff -Nupr src.orig/fs/proc/proc_sysctl.c src/fs/proc/proc_sysctl.c +--- src.orig/fs/proc/proc_sysctl.c 2017-09-22 15:27:21.698056175 -0400 ++++ src/fs/proc/proc_sysctl.c 2017-09-22 15:27:21.769056469 -0400 +@@ -266,6 +266,8 @@ void sysctl_head_put(struct ctl_table_he + + static struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) + { ++ if (jiffies == 0) ++ printk("kpatch-test: testing __bug_table section changes\n"); + BUG_ON(!head); + spin_lock(&sysctl_lock); + if (!use_table(head))
  20. Download patch kpatch-build/log.h

    --- 0.3.2-3.1/kpatch-build/log.h 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/kpatch-build/log.h 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,26 @@ +#ifndef _LOG_H_ +#define _LOG_H_ + +#include <error.h> + +/* Files that include log.h must define loglevel and childobj */ +extern enum loglevel loglevel; +extern char *childobj; + +#define ERROR(format, ...) \ + error(1, 0, "ERROR: %s: %s: %d: " format, childobj, __FUNCTION__, __LINE__, ##__VA_ARGS__) + +#define log_debug(format, ...) log(DEBUG, format, ##__VA_ARGS__) +#define log_normal(format, ...) log(NORMAL, "%s: " format, childobj, ##__VA_ARGS__) + +#define log(level, format, ...) \ +({ \ + if (loglevel <= (level)) \ + printf(format, ##__VA_ARGS__); \ +}) + +enum loglevel { + DEBUG, + NORMAL +}; +#endif /* _LOG_H_ */
  21. Download patch doc/patch-author-guide.md
  22. Download patch test/integration/centos-7/README

    --- 0.3.2-3.1/test/integration/centos-7/README 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/README 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1 @@ +3.10.0-327.36.3.el7.x86_64
  23. Download patch test/integration/centos-7/module-shadow.patch

    --- 0.3.2-3.1/test/integration/centos-7/module-shadow.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/module-shadow.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,24 @@ +diff -Nupr src.orig/arch/x86/kvm/vmx.c src/arch/x86/kvm/vmx.c +--- src.orig/arch/x86/kvm/vmx.c 2017-09-22 15:27:20.853052676 -0400 ++++ src/arch/x86/kvm/vmx.c 2017-09-22 15:27:44.742151601 -0400 +@@ -10581,10 +10581,20 @@ static void vmx_leave_nested(struct kvm_ + * It should only be called before L2 actually succeeded to run, and when + * vmcs01 is current (it doesn't leave_guest_mode() or switch vmcss). + */ ++#include "kpatch.h" + static void nested_vmx_entry_failure(struct kvm_vcpu *vcpu, + struct vmcs12 *vmcs12, + u32 reason, unsigned long qualification) + { ++ int *kpatch; ++ ++ kpatch = kpatch_shadow_alloc(vcpu, "kpatch", sizeof(*kpatch), ++ GFP_KERNEL); ++ if (kpatch) { ++ kpatch_shadow_get(vcpu, "kpatch"); ++ kpatch_shadow_free(vcpu, "kpatch"); ++ } ++ + load_vmcs12_host_state(vcpu, vmcs12); + vmcs12->vm_exit_reason = reason | VMX_EXIT_REASONS_FAILED_VMENTRY; + vmcs12->exit_qualification = qualification;
  24. Download patch kpatch-build/gcc-plugins/gcc-generate-rtl-pass.h

    --- 0.3.2-3.1/kpatch-build/gcc-plugins/gcc-generate-rtl-pass.h 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/kpatch-build/gcc-plugins/gcc-generate-rtl-pass.h 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,176 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Generator for RTL pass related boilerplate code/data + * + * Supports gcc 4.5-6 + * + * Usage: + * + * 1. before inclusion define PASS_NAME + * 2. before inclusion define NO_* for unimplemented callbacks + * NO_GATE + * NO_EXECUTE + * 3. before inclusion define PROPERTIES_* and TODO_FLAGS_* to override + * the default 0 values + * 4. for convenience, all the above will be undefined after inclusion! + * 5. the only exported name is make_PASS_NAME_pass() to register with gcc + */ + +#ifndef PASS_NAME +#error at least PASS_NAME must be defined +#else +#define __GCC_PLUGIN_STRINGIFY(n) #n +#define _GCC_PLUGIN_STRINGIFY(n) __GCC_PLUGIN_STRINGIFY(n) +#define _GCC_PLUGIN_CONCAT2(x, y) x ## y +#define _GCC_PLUGIN_CONCAT3(x, y, z) x ## y ## z + +#define __PASS_NAME_PASS_DATA(n) _GCC_PLUGIN_CONCAT2(n, _pass_data) +#define _PASS_NAME_PASS_DATA __PASS_NAME_PASS_DATA(PASS_NAME) + +#define __PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT2(n, _pass) +#define _PASS_NAME_PASS __PASS_NAME_PASS(PASS_NAME) + +#define _PASS_NAME_NAME _GCC_PLUGIN_STRINGIFY(PASS_NAME) + +#define __MAKE_PASS_NAME_PASS(n) _GCC_PLUGIN_CONCAT3(make_, n, _pass) +#define _MAKE_PASS_NAME_PASS __MAKE_PASS_NAME_PASS(PASS_NAME) + +#ifdef NO_GATE +#define _GATE NULL +#define _HAS_GATE false +#else +#define __GATE(n) _GCC_PLUGIN_CONCAT2(n, _gate) +#define _GATE __GATE(PASS_NAME) +#define _HAS_GATE true +#endif + +#ifdef NO_EXECUTE +#define _EXECUTE NULL +#define _HAS_EXECUTE false +#else +#define __EXECUTE(n) _GCC_PLUGIN_CONCAT2(n, _execute) +#define _EXECUTE __EXECUTE(PASS_NAME) +#define _HAS_EXECUTE true +#endif + +#ifndef PROPERTIES_REQUIRED +#define PROPERTIES_REQUIRED 0 +#endif + +#ifndef PROPERTIES_PROVIDED +#define PROPERTIES_PROVIDED 0 +#endif + +#ifndef PROPERTIES_DESTROYED +#define PROPERTIES_DESTROYED 0 +#endif + +#ifndef TODO_FLAGS_START +#define TODO_FLAGS_START 0 +#endif + +#ifndef TODO_FLAGS_FINISH +#define TODO_FLAGS_FINISH 0 +#endif + +#if BUILDING_GCC_VERSION >= 4009 +namespace { +static const pass_data _PASS_NAME_PASS_DATA = { +#else +static struct rtl_opt_pass _PASS_NAME_PASS = { + .pass = { +#endif + .type = RTL_PASS, + .name = _PASS_NAME_NAME, +#if BUILDING_GCC_VERSION >= 4008 + .optinfo_flags = OPTGROUP_NONE, +#endif +#if BUILDING_GCC_VERSION >= 5000 +#elif BUILDING_GCC_VERSION == 4009 + .has_gate = _HAS_GATE, + .has_execute = _HAS_EXECUTE, +#else + .gate = _GATE, + .execute = _EXECUTE, + .sub = NULL, + .next = NULL, + .static_pass_number = 0, +#endif + .tv_id = TV_NONE, + .properties_required = PROPERTIES_REQUIRED, + .properties_provided = PROPERTIES_PROVIDED, + .properties_destroyed = PROPERTIES_DESTROYED, + .todo_flags_start = TODO_FLAGS_START, + .todo_flags_finish = TODO_FLAGS_FINISH, +#if BUILDING_GCC_VERSION < 4009 + } +#endif +}; + +#if BUILDING_GCC_VERSION >= 4009 +class _PASS_NAME_PASS : public rtl_opt_pass { +public: + _PASS_NAME_PASS() : rtl_opt_pass(_PASS_NAME_PASS_DATA, g) {} + +#ifndef NO_GATE +#if BUILDING_GCC_VERSION >= 5000 + virtual bool gate(function *) { return _GATE(); } +#else + virtual bool gate(void) { return _GATE(); } +#endif +#endif + + virtual opt_pass *clone() { return new _PASS_NAME_PASS(); } + +#ifndef NO_EXECUTE +#if BUILDING_GCC_VERSION >= 5000 + virtual unsigned int execute(function *) { return _EXECUTE(); } +#else + virtual unsigned int execute(void) { return _EXECUTE(); } +#endif +#endif +}; +} + +opt_pass *_MAKE_PASS_NAME_PASS(void) +{ + return new _PASS_NAME_PASS(); +} +#else +struct opt_pass *_MAKE_PASS_NAME_PASS(void) +{ + return &_PASS_NAME_PASS.pass; +} +#endif + +/* clean up user provided defines */ +#undef PASS_NAME +#undef NO_GATE +#undef NO_EXECUTE + +#undef PROPERTIES_DESTROYED +#undef PROPERTIES_PROVIDED +#undef PROPERTIES_REQUIRED +#undef TODO_FLAGS_FINISH +#undef TODO_FLAGS_START + +/* clean up generated defines */ +#undef _EXECUTE +#undef __EXECUTE +#undef _GATE +#undef __GATE +#undef _GCC_PLUGIN_CONCAT2 +#undef _GCC_PLUGIN_CONCAT3 +#undef _GCC_PLUGIN_STRINGIFY +#undef __GCC_PLUGIN_STRINGIFY +#undef _HAS_EXECUTE +#undef _HAS_GATE +#undef _MAKE_PASS_NAME_PASS +#undef __MAKE_PASS_NAME_PASS +#undef _PASS_NAME_NAME +#undef _PASS_NAME_PASS +#undef __PASS_NAME_PASS +#undef _PASS_NAME_PASS_DATA +#undef __PASS_NAME_PASS_DATA + +#endif /* PASS_NAME */
  25. Download patch kpatch-build/create-klp-module.c
  26. Download patch kpatch-build/gcc-plugins/gcc-common.h
  27. Download patch debian/control

    --- 0.3.2-3.1/debian/control 2016-06-27 19:03:09.000000000 +0000 +++ 0.5.0-0ubuntu2/debian/control 2018-04-12 01:41:51.000000000 +0000 @@ -1,8 +1,9 @@ Source: kpatch Section: kernel Priority: optional -Maintainer: Chris J Arges <chris.j.arges@canonical.com> -Build-Depends: debhelper (>= 9), libelf-dev, dkms +Maintainer: Ubuntu Kernel Team <kernel-team@lists.ubuntu.com> +XSBC-Original-Maintainer: Chris J Arges <chris.j.arges@canonical.com> +Build-Depends: debhelper (>= 9), libelf-dev, dkms, shellcheck Standards-Version: 3.9.8 Homepage: http://github.com/dynup/kpatch #Vcs-Git: git://anonscm.debian.org/collab-maint/kpatch.git @@ -30,7 +31,12 @@ Description: DKMS module for Kpatch Package: kpatch-build Architecture: linux-amd64 -Depends: ${shlibs:Depends}, ${misc:Depends}, dpkg-dev, linux-source, kernel-wedge, gawk, bc +Depends: ${shlibs:Depends}, ${misc:Depends}, dpkg-dev, debhelper (>= 5), + dh-systemd, cpio, kernel-wedge, kmod, makedumpfile, libelf-dev, + libnewt-dev, libiberty-dev, rsync, libdw-dev, libpci-dev, pkg-config, flex, + bison, libunwind8-dev, openssl, libssl-dev, libaudit-dev, bc, python-dev, gawk, + libudev-dev, autoconf, automake, libtool, uuid-dev, xmlto, docbook-utils, + ghostscript, transfig, bzip2, sharutils, asciidoc Suggests: ccache Description: Build Tools for Kpatch and Livepatch kpatch-build is a tool that can build both kpatch and livepatch modules from
  28. Download patch kpatch-build/Makefile

    --- 0.3.2-3.1/kpatch-build/Makefile 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/kpatch-build/Makefile 2017-12-21 05:02:48.000000000 +0000 @@ -1,25 +1,41 @@ include ../Makefile.inc -CFLAGS += -I../kmod/patch -Iinsn -Wall -g -Werror -LDFLAGS += -lelf +CFLAGS += -MMD -MP -I../kmod/patch -Iinsn -Wall -g -Werror +LDLIBS = -lelf + +TARGETS = create-diff-object create-klp-module create-kpatch-module +SOURCES = create-diff-object.c kpatch-elf.c \ + create-klp-module.c \ + create-kpatch-module.c \ + create-kpatch-module.c lookup.c + +ifeq ($(ARCH),x86_64) +SOURCES += insn/insn.c insn/inat.c +INSN = insn/insn.o insn/inat.o +else ifeq ($(ARCH),ppc64le) +SOURCES += gcc-plugins/ppc64le-plugin.c +PLUGIN = gcc-plugins/ppc64le-plugin.so +TARGETS += $(PLUGIN) +GCC_PLUGINS_DIR := $(shell gcc -print-file-name=plugin) +PLUGIN_CFLAGS = -shared $(CFLAGS) -I$(GCC_PLUGINS_DIR)/include \ + -Igcc-plugins -fPIC -fno-rtti -O2 -Wall +endif -TARGETS = create-diff-object -OBJS = create-diff-object.o lookup.o insn/insn.o insn/inat.o -SOURCES = create-diff-object.c lookup.c insn/insn.c insn/inat.c all: $(TARGETS) -include $(SOURCES:.c=.d) -%.o : %.c - $(CC) -MMD -MP $(CFLAGS) -c -o $@ $< +create-diff-object: create-diff-object.o kpatch-elf.o lookup.o $(INSN) +create-klp-module: create-klp-module.o kpatch-elf.o +create-kpatch-module: create-kpatch-module.o kpatch-elf.o -create-diff-object: $(OBJS) - $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) +$(PLUGIN): gcc-plugins/ppc64le-plugin.c + g++ $(PLUGIN_CFLAGS) $< -o $@ install: all $(INSTALL) -d $(LIBEXECDIR) - $(INSTALL) $(TARGETS) kpatch-gcc $(LIBEXECDIR) + $(INSTALL) $(TARGETS) kpatch-gcc $(PLUGIN) $(LIBEXECDIR) $(INSTALL) -d $(BINDIR) $(INSTALL) kpatch-build $(BINDIR) @@ -28,4 +44,4 @@ uninstall: $(RM) $(BINDIR)/kpatch-build clean: - $(RM) $(TARGETS) $(OBJS) *.d insn/*.d + $(RM) $(TARGETS) *.{o,d} insn/*.{o,d} gcc-plugins/*.{so,d}
  29. Download patch kpatch-build/kpatch-build
  30. Download patch test/integration/centos-7/data-new.patch

    --- 0.3.2-3.1/test/integration/centos-7/data-new.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/data-new.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,28 @@ +diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c +--- src.orig/fs/proc/meminfo.c 2017-09-22 15:27:21.699056179 -0400 ++++ src/fs/proc/meminfo.c 2017-09-22 15:27:24.102066130 -0400 +@@ -20,6 +20,8 @@ void __attribute__((weak)) arch_report_m + { + } + ++static int foo = 5; ++ + static int meminfo_proc_show(struct seq_file *m, void *v) + { + struct sysinfo i; +@@ -106,6 +108,7 @@ static int meminfo_proc_show(struct seq_ + #ifdef CONFIG_TRANSPARENT_HUGEPAGE + "AnonHugePages: %8lu kB\n" + #endif ++ "kpatch: %d" + , + K(i.totalram), + K(i.freeram), +@@ -167,6 +170,7 @@ static int meminfo_proc_show(struct seq_ + ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) * + HPAGE_PMD_NR) + #endif ++ ,foo + ); + + hugetlb_report_meminfo(m);
  31. Download patch kpatch-build/kpatch-intermediate.h

    --- 0.3.2-3.1/kpatch-build/kpatch-intermediate.h 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/kpatch-build/kpatch-intermediate.h 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,48 @@ +/* + * kpatch-intermediate.h + * + * Structures for intermediate .kpatch.* sections + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, + * 02110-1301, USA. + */ + +#ifndef _KPATCH_INTERMEDIATE_H_ +#define _KPATCH_INTERMEDIATE_H_ + +/* For .kpatch.{symbols,relocations,arch} sections */ + +struct kpatch_symbol { + unsigned long src; + unsigned long pos; + unsigned char bind, type; + char *name; + char *objname; /* object to which this sym belongs */ +}; + +struct kpatch_relocation { + unsigned long dest; + unsigned int type; + int addend; + int external; + char *objname; /* object to which this rela applies to */ + struct kpatch_symbol *ksym; +}; + +struct kpatch_arch { + unsigned long sec; + char *objname; +}; +#endif /* _KPATCH_INTERMEDIATE_H_ */
  32. Download patch test/integration/centos-7/new-function.patch

    --- 0.3.2-3.1/test/integration/centos-7/new-function.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/new-function.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,25 @@ +diff -Nupr src.orig/drivers/tty/n_tty.c src/drivers/tty/n_tty.c +--- src.orig/drivers/tty/n_tty.c 2017-09-22 15:27:21.084053633 -0400 ++++ src/drivers/tty/n_tty.c 2017-09-22 15:27:45.888156346 -0400 +@@ -2016,7 +2016,7 @@ do_it_again: + * lock themselves) + */ + +-static ssize_t n_tty_write(struct tty_struct *tty, struct file *file, ++static ssize_t noinline kpatch_n_tty_write(struct tty_struct *tty, struct file *file, + const unsigned char *buf, size_t nr) + { + const unsigned char *b = buf; +@@ -2098,6 +2098,12 @@ break_out: + return (b - buf) ? b - buf : retval; + } + ++static ssize_t n_tty_write(struct tty_struct *tty, struct file *file, ++ const unsigned char *buf, size_t nr) ++{ ++ return kpatch_n_tty_write(tty, file, buf, nr); ++} ++ + /** + * n_tty_poll - poll method for N_TTY + * @tty: terminal device
  33. Download patch test/integration/centos-7/gcc-static-local-var-2.patch

    --- 0.3.2-3.1/test/integration/centos-7/gcc-static-local-var-2.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/gcc-static-local-var-2.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,21 @@ +diff -Nupr src.orig/mm/mmap.c src/mm/mmap.c +--- src.orig/mm/mmap.c 2017-09-22 15:27:21.618055844 -0400 ++++ src/mm/mmap.c 2017-09-22 15:27:31.024094794 -0400 +@@ -1677,6 +1677,7 @@ static inline int accountable_mapping(st + return (vm_flags & (VM_NORESERVE | VM_SHARED | VM_WRITE)) == VM_WRITE; + } + ++#include "kpatch-macros.h" + unsigned long mmap_region(struct file *file, unsigned long addr, + unsigned long len, vm_flags_t vm_flags, unsigned long pgoff, + struct list_head *uf) +@@ -1687,6 +1688,9 @@ unsigned long mmap_region(struct file *f + struct rb_node **rb_link, *rb_parent; + unsigned long charged = 0; + ++ if (!jiffies) ++ printk("kpatch mmap foo\n"); ++ + /* Check against address space limit. */ + if (!may_expand_vm(mm, len >> PAGE_SHIFT)) { + unsigned long nr_pages;
  34. Download patch kmod/patch/kpatch.h

    --- 0.3.2-3.1/kmod/patch/kpatch.h 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/kmod/patch/kpatch.h 2017-12-21 05:02:48.000000000 +0000 @@ -38,6 +38,7 @@ struct kpatch_func { unsigned long new_size; unsigned long old_addr; unsigned long old_size; + unsigned long sympos; const char *name; struct list_head list; int force; @@ -45,12 +46,14 @@ struct kpatch_func { /* private */ struct hlist_node node; enum kpatch_op op; + struct kobject kobj; }; struct kpatch_dynrela { unsigned long dest; unsigned long src; unsigned long type; + unsigned long sympos; const char *name; int addend; int external; @@ -72,6 +75,7 @@ struct kpatch_object { /* private */ struct module *mod; + struct kobject kobj; }; struct kpatch_module { @@ -84,9 +88,10 @@ struct kpatch_module { /* private */ struct list_head list; + struct kobject kobj; }; -extern struct kobject *kpatch_patches_kobj; +extern struct kobject *kpatch_root_kobj; extern int kpatch_register(struct kpatch_module *kpmod, bool replace); extern int kpatch_unregister(struct kpatch_module *kpmod);
  35. Download patch test/integration/centos-7/macro-printk.patch

    --- 0.3.2-3.1/test/integration/centos-7/macro-printk.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/macro-printk.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,147 @@ +diff -Nupr src.orig/net/ipv4/fib_frontend.c src/net/ipv4/fib_frontend.c +--- src.orig/net/ipv4/fib_frontend.c 2017-09-22 16:52:10.646110299 -0400 ++++ src/net/ipv4/fib_frontend.c 2017-09-22 16:55:14.395870305 -0400 +@@ -633,6 +633,7 @@ errout: + return err; + } + ++#include "kpatch-macros.h" + static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh) + { + struct net *net = sock_net(skb->sk); +@@ -651,6 +652,7 @@ static int inet_rtm_newroute(struct sk_b + } + + err = fib_table_insert(net, tb, &cfg); ++ KPATCH_PRINTK("[inet_rtm_newroute]: err is %d\n", err); + errout: + return err; + } +diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c +--- src.orig/net/ipv4/fib_semantics.c 2017-09-22 16:52:10.645110295 -0400 ++++ src/net/ipv4/fib_semantics.c 2017-09-22 16:54:05.175584004 -0400 +@@ -925,6 +925,7 @@ fib_convert_metrics(struct fib_info *fi, + return 0; + } + ++#include "kpatch-macros.h" + struct fib_info *fib_create_info(struct fib_config *cfg) + { + int err; +@@ -949,6 +950,7 @@ struct fib_info *fib_create_info(struct + #endif + + err = -ENOBUFS; ++ KPATCH_PRINTK("[fib_create_info]: create error err is %d\n",err); + if (fib_info_cnt >= fib_info_hash_size) { + unsigned int new_size = fib_info_hash_size << 1; + struct hlist_head *new_info_hash; +@@ -969,6 +971,7 @@ struct fib_info *fib_create_info(struct + if (!fib_info_hash_size) + goto failure; + } ++ KPATCH_PRINTK("[fib_create_info]: 2 create error err is %d\n",err); + + fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL); + if (fi == NULL) +@@ -980,6 +983,7 @@ struct fib_info *fib_create_info(struct + } else + fi->fib_metrics = (u32 *) dst_default_metrics; + fib_info_cnt++; ++ KPATCH_PRINTK("[fib_create_info]: 3 create error err is %d\n",err); + + fi->fib_net = net; + fi->fib_protocol = cfg->fc_protocol; +@@ -996,8 +1000,10 @@ struct fib_info *fib_create_info(struct + if (!nexthop_nh->nh_pcpu_rth_output) + goto failure; + } endfor_nexthops(fi) ++ KPATCH_PRINTK("[fib_create_info]: 4 create error err is %d\n",err); + + err = fib_convert_metrics(fi, cfg); ++ KPATCH_PRINTK("[fib_create_info]: 5 create error err is %d\n",err); + if (err) + goto failure; + +@@ -1048,6 +1054,7 @@ struct fib_info *fib_create_info(struct + nh->nh_weight = 1; + #endif + } ++ KPATCH_PRINTK("[fib_create_info]: 6 create error err is %d\n",err); + + if (fib_props[cfg->fc_type].error) { + if (cfg->fc_gw || cfg->fc_oif || cfg->fc_mp) +@@ -1065,6 +1072,7 @@ struct fib_info *fib_create_info(struct + goto err_inval; + } + } ++ KPATCH_PRINTK("[fib_create_info]: 7 create error err is %d\n",err); + + if (cfg->fc_scope > RT_SCOPE_HOST) + goto err_inval; +@@ -1087,6 +1095,7 @@ struct fib_info *fib_create_info(struct + goto failure; + } endfor_nexthops(fi) + } ++ KPATCH_PRINTK("[fib_create_info]: 8 create error err is %d\n",err); + + if (fi->fib_prefsrc) { + if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst || +@@ -1099,6 +1108,7 @@ struct fib_info *fib_create_info(struct + fib_info_update_nh_saddr(net, nexthop_nh); + fib_add_weight(fi, nexthop_nh); + } endfor_nexthops(fi) ++ KPATCH_PRINTK("[fib_create_info]: 9 create error err is %d\n",err); + + fib_rebalance(fi); + +@@ -1110,6 +1120,7 @@ link_it: + ofi->fib_treeref++; + return ofi; + } ++ KPATCH_PRINTK("[fib_create_info]: 10 create error err is %d\n",err); + + fi->fib_treeref++; + atomic_inc(&fi->fib_clntref); +@@ -1133,6 +1144,7 @@ link_it: + hlist_add_head(&nexthop_nh->nh_hash, head); + } endfor_nexthops(fi) + spin_unlock_bh(&fib_info_lock); ++ KPATCH_PRINTK("[fib_create_info]: 11 create error err is %d\n",err); + return fi; + + err_inval: +@@ -1143,6 +1155,7 @@ failure: + fi->fib_dead = 1; + free_fib_info(fi); + } ++ KPATCH_PRINTK("[fib_create_info]: 12 create error err is %d\n",err); + + return ERR_PTR(err); + } +diff -Nupr src.orig/net/ipv4/fib_trie.c src/net/ipv4/fib_trie.c +--- src.orig/net/ipv4/fib_trie.c 2017-09-22 16:52:10.645110295 -0400 ++++ src/net/ipv4/fib_trie.c 2017-09-22 16:55:39.940975963 -0400 +@@ -1191,6 +1191,7 @@ static int fib_insert_alias(struct trie + } + + /* Caller must hold RTNL. */ ++#include "kpatch-macros.h" + int fib_table_insert(struct net *net, struct fib_table *tb, + struct fib_config *cfg) + { +@@ -1216,11 +1217,14 @@ int fib_table_insert(struct net *net, st + if ((plen < KEYLENGTH) && (key << plen)) + return -EINVAL; + ++ KPATCH_PRINTK("[fib_table_insert]: start\n"); + fi = fib_create_info(cfg); + if (IS_ERR(fi)) { + err = PTR_ERR(fi); ++ KPATCH_PRINTK("[fib_table_insert]: create error err is %d\n",err); + goto err; + } ++ KPATCH_PRINTK("[fib_table_insert]: cross\n"); + + l = fib_find_node(t, &tp, key); + fa = l ? fib_find_alias(&l->leaf, slen, tos, fi->fib_priority) : NULL;
  36. Download patch test/integration/centos-7/gcc-mangled-3.patch

    --- 0.3.2-3.1/test/integration/centos-7/gcc-mangled-3.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/gcc-mangled-3.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,13 @@ +diff -Nupr src.orig/mm/slub.c src/mm/slub.c +--- src.orig/mm/slub.c 2017-09-22 15:27:21.618055844 -0400 ++++ src/mm/slub.c 2017-09-22 15:27:29.830089850 -0400 +@@ -5528,6 +5528,9 @@ void get_slabinfo(struct kmem_cache *s, + unsigned long nr_free = 0; + int node; + ++ if (!jiffies) ++ printk("slabinfo\n"); ++ + for_each_online_node(node) { + struct kmem_cache_node *n = get_node(s, node); +
  37. Download patch test/integration/centos-7/gcc-static-local-var.patch

    --- 0.3.2-3.1/test/integration/centos-7/gcc-static-local-var.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/gcc-static-local-var.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,25 @@ +diff -Nupr src.orig/arch/x86/kernel/ldt.c src/arch/x86/kernel/ldt.c +--- src.orig/arch/x86/kernel/ldt.c 2017-09-22 15:27:20.847052651 -0400 ++++ src/arch/x86/kernel/ldt.c 2017-09-22 15:27:35.573113632 -0400 +@@ -98,6 +98,12 @@ static inline int copy_ldt(mm_context_t + return 0; + } + ++void hi_there(void) ++{ ++ if (!jiffies) ++ printk("hi there\n"); ++} ++ + /* + * we do not have to muck with descriptors here, that is + * done in switch_mm() as needed. +@@ -107,6 +113,8 @@ int init_new_context(struct task_struct + struct mm_struct *old_mm; + int retval = 0; + ++ hi_there(); ++ + mutex_init(&mm->context.lock); + mm->context.size = 0; + old_mm = current->mm;
  38. Download patch test/integration/centos-7/smp-locks-section.patch

    --- 0.3.2-3.1/test/integration/centos-7/smp-locks-section.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/smp-locks-section.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,14 @@ +diff -Nupr src.orig/drivers/tty/tty_buffer.c src/drivers/tty/tty_buffer.c +--- src.orig/drivers/tty/tty_buffer.c 2017-09-22 15:27:21.077053604 -0400 ++++ src/drivers/tty/tty_buffer.c 2017-09-22 15:27:50.542175618 -0400 +@@ -217,6 +217,10 @@ int tty_buffer_request_room(struct tty_p + /* OPTIMISATION: We could keep a per tty "zero" sized buffer to + remove this conditional if its worth it. This would be invisible + to the callers */ ++ ++ if (!size) ++ printk("kpatch-test: testing .smp_locks section changes\n"); ++ + b = buf->tail; + if (b != NULL) + left = b->size - b->used;
  39. Download patch test/integration/centos-7/gcc-static-local-var-3.patch

    --- 0.3.2-3.1/test/integration/centos-7/gcc-static-local-var-3.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/gcc-static-local-var-3.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,19 @@ +diff -Nupr src.orig/kernel/sys.c src/kernel/sys.c +--- src.orig/kernel/sys.c 2017-09-22 15:27:21.601055773 -0400 ++++ src/kernel/sys.c 2017-09-22 15:27:32.170099540 -0400 +@@ -554,8 +554,15 @@ SYSCALL_DEFINE4(reboot, int, magic1, int + return ret; + } + ++void kpatch_bar(void) ++{ ++ if (!jiffies) ++ printk("kpatch_foo\n"); ++} ++ + static void deferred_cad(struct work_struct *dummy) + { ++ kpatch_bar(); + kernel_restart(NULL); + } +
  40. Download patch test/integration/centos-7/gcc-static-local-var-4.patch

    --- 0.3.2-3.1/test/integration/centos-7/gcc-static-local-var-4.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/gcc-static-local-var-4.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,20 @@ +diff -Nupr src.orig/fs/aio.c src/fs/aio.c +--- src.orig/fs/aio.c 2017-09-22 15:27:21.702056192 -0400 ++++ src/fs/aio.c 2017-09-22 15:27:33.299104215 -0400 +@@ -219,9 +219,16 @@ static int __init aio_setup(void) + } + __initcall(aio_setup); + ++void kpatch_aio_foo(void) ++{ ++ if (!jiffies) ++ printk("kpatch aio foo\n"); ++} ++ + static void put_aio_ring_file(struct kioctx *ctx) + { + struct file *aio_ring_file = ctx->aio_ring_file; ++ kpatch_aio_foo(); + if (aio_ring_file) { + truncate_setsize(aio_ring_file->f_inode, 0); +
  41. Download patch kmod/core/shadow.c

    --- 0.3.2-3.1/kmod/core/shadow.c 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/kmod/core/shadow.c 2017-12-21 05:02:48.000000000 +0000 @@ -93,8 +93,10 @@ void *kpatch_shadow_alloc(void *obj, cha shadow->obj = obj; shadow->var = kstrdup(var, gfp); - if (!shadow->var) + if (!shadow->var) { + kfree(shadow); return NULL; + } if (size <= sizeof(shadow->data)) { shadow->data = &shadow->data; @@ -103,6 +105,7 @@ void *kpatch_shadow_alloc(void *obj, cha shadow->data = kmalloc(size, gfp); if (!shadow->data) { kfree(shadow->var); + kfree(shadow); return NULL; } }
  42. Download patch kmod/patch/kpatch-patch-hook.c
  43. Download patch test/integration/f22/cmdline-string-LOADED.test

    --- 0.3.2-3.1/test/integration/f22/cmdline-string-LOADED.test 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/f22/cmdline-string-LOADED.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -#!/bin/bash - -grep kpatch=1 /proc/cmdline
  44. Download patch kmod/core/core.c
  45. Download patch .gitignore

    --- 0.3.2-3.1/.gitignore 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/.gitignore 2017-12-21 05:02:48.000000000 +0000 @@ -6,9 +6,12 @@ *.mod.c *.swp *.d +*.so .tmp_versions Module.symvers kpatch-build/lookup kpatch-build/create-diff-object +kpatch-build/create-klp-module +kpatch-build/create-kpatch-module man/kpatch.1.gz man/kpatch-build.1.gz
  46. Download patch test/integration/centos-7/special-static-2.patch

    --- 0.3.2-3.1/test/integration/centos-7/special-static-2.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/special-static-2.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,24 @@ +diff -Nupr src.orig/arch/x86/kvm/x86.c src/arch/x86/kvm/x86.c +--- src.orig/arch/x86/kvm/x86.c 2017-09-22 15:27:20.852052672 -0400 ++++ src/arch/x86/kvm/x86.c 2017-09-22 15:27:51.744180596 -0400 +@@ -2093,12 +2093,20 @@ static void record_steal_time(struct kvm + &vcpu->arch.st.steal, sizeof(struct kvm_steal_time)); + } + ++void kpatch_kvm_x86_foo(void) ++{ ++ if (!jiffies) ++ printk("kpatch kvm x86 foo\n"); ++} ++ + int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) + { + bool pr = false; + u32 msr = msr_info->index; + u64 data = msr_info->data; + ++ kpatch_kvm_x86_foo(); ++ + switch (msr) { + case MSR_AMD64_NB_CFG: + case MSR_IA32_UCODE_REV:
  47. Download patch kpatch-build/create-kpatch-module.c
  48. Download patch test/integration/centos-7/replace-section-references.patch

    --- 0.3.2-3.1/test/integration/centos-7/replace-section-references.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/replace-section-references.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,12 @@ +diff -Nupr src.orig/arch/x86/kvm/x86.c src/arch/x86/kvm/x86.c +--- src.orig/arch/x86/kvm/x86.c 2017-09-22 15:27:20.852052672 -0400 ++++ src/arch/x86/kvm/x86.c 2017-09-22 15:27:49.362170732 -0400 +@@ -248,6 +248,8 @@ static void shared_msr_update(unsigned s + + void kvm_define_shared_msr(unsigned slot, u32 msr) + { ++ if (!jiffies) ++ printk("kpatch kvm define shared msr\n"); + BUG_ON(slot >= KVM_NR_SHARED_MSRS); + shared_msrs_global.msrs[slot] = msr; + if (slot >= shared_msrs_global.nr)
  49. Download patch test/integration/centos-7/macro-hooks.patch

    --- 0.3.2-3.1/test/integration/centos-7/macro-hooks.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/macro-hooks.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,24 @@ +diff -Nupr src.orig/fs/aio.c src/fs/aio.c +--- src.orig/fs/aio.c 2017-09-22 15:27:21.702056192 -0400 ++++ src/fs/aio.c 2017-09-22 15:27:36.703118311 -0400 +@@ -1683,6 +1683,20 @@ SYSCALL_DEFINE3(io_cancel, aio_context_t + return ret; + } + ++static int aio_max_nr_orig; ++void kpatch_load_aio_max_nr(void) ++{ ++ aio_max_nr_orig = aio_max_nr; ++ aio_max_nr = 0x40000; ++} ++void kpatch_unload_aio_max_nr(void) ++{ ++ aio_max_nr = aio_max_nr_orig; ++} ++#include "kpatch-macros.h" ++KPATCH_LOAD_HOOK(kpatch_load_aio_max_nr); ++KPATCH_UNLOAD_HOOK(kpatch_unload_aio_max_nr); ++ + /* io_getevents: + * Attempts to read at least min_nr events and up to nr events from + * the completion queue for the aio_context specified by ctx_id. If
  50. Download patch debian/patches/kpatch-build-adjust-dirs.patch

    --- 0.3.2-3.1/debian/patches/kpatch-build-adjust-dirs.patch 2016-02-18 16:46:39.000000000 +0000 +++ 0.5.0-0ubuntu2/debian/patches/kpatch-build-adjust-dirs.patch 2018-04-12 01:41:51.000000000 +0000 @@ -3,26 +3,35 @@ Description: adjust kpatch-build directo paths to adjust for this. In addition the debian packaging uses /usr/lib instead of /usr/libexec for internal binaries. Author: Chris J Arges <chris.j.arges@canonical.com> -Last-Update: 2016-01-08 +Last-Update: 2018-02-07 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build -@@ -99,14 +99,14 @@ - DATADIR="$(readlink -f $SCRIPTDIR/../kmod)" +@@ -159,9 +159,9 @@ + TOOLSDIR="$SCRIPTDIR" + DATADIR="$(readlink -f "$SCRIPTDIR/../kmod")" + PLUGINDIR="$(readlink -f "$SCRIPTDIR/gcc-plugins")" +- elif [[ -e "$SCRIPTDIR/../libexec/kpatch/create-diff-object" ]]; then ++ elif [[ -e "$SCRIPTDIR/../lib/kpatch/create-diff-object" ]]; then + # installation path +- TOOLSDIR="$(readlink -f "$SCRIPTDIR/../libexec/kpatch")" ++ TOOLSDIR="$(readlink -f "$SCRIPTDIR/../lib/kpatch")" + DATADIR="$(readlink -f "$SCRIPTDIR/../share/kpatch")" + PLUGINDIR="$TOOLSDIR" + else +@@ -174,12 +174,12 @@ + if [[ -e "$SCRIPTDIR/create-diff-object" ]]; then + # git repo SYMVERSFILE="$DATADIR/core/Module.symvers" - return - elif [[ -e "$SCRIPTDIR/../libexec/kpatch/create-diff-object" ]]; then + elif [[ -e "$SCRIPTDIR/../lib/kpatch/create-diff-object" ]]; then # installation path -- TOOLSDIR="$(readlink -f $SCRIPTDIR/../libexec/kpatch)" -+ TOOLSDIR="$(readlink -f $SCRIPTDIR/../lib/kpatch)" - DATADIR="$(readlink -f $SCRIPTDIR/../share/kpatch)" - if [[ -e $SCRIPTDIR/../lib/kpatch/$ARCHVERSION/Module.symvers ]]; then - SYMVERSFILE="$(readlink -f $SCRIPTDIR/../lib/kpatch/$ARCHVERSION/Module.symvers)" + if [[ -e "$SCRIPTDIR/../lib/kpatch/$ARCHVERSION/Module.symvers" ]]; then + SYMVERSFILE="$(readlink -f "$SCRIPTDIR/../lib/kpatch/$ARCHVERSION/Module.symvers")" - elif [[ -e /lib/modules/$ARCHVERSION/extra/kpatch/Module.symvers ]]; then -- SYMVERSFILE="$(readlink -f /lib/modules/$ARCHVERSION/extra/kpatch/Module.symvers)" +- SYMVERSFILE="$(readlink -f "/lib/modules/$ARCHVERSION/extra/kpatch/Module.symvers")" + elif [[ -e /lib/modules/$ARCHVERSION/updates/dkms/kpatch.Module.symvers ]]; then -+ SYMVERSFILE="$(readlink -f /lib/modules/$ARCHVERSION/updates/dkms/kpatch.Module.symvers)" - else - warn "unable to find Module.symvers for kpatch core module" - return 1 ++ SYMVERSFILE="$(readlink -f "/lib/modules/$ARCHVERSION/updates/dkms/kpatch.Module.symvers")" + fi + fi +
  51. Download patch kpatch-build/kpatch-elf.c
  52. Download patch test/integration/f22/gcc-isra.patch

    --- 0.3.2-3.1/test/integration/f22/gcc-isra.patch 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/f22/gcc-isra.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -Index: src/fs/proc/proc_sysctl.c -=================================================================== ---- src.orig/fs/proc/proc_sysctl.c -+++ src/fs/proc/proc_sysctl.c -@@ -24,6 +24,7 @@ void proc_sys_poll_notify(struct ctl_tab - if (!poll) - return; - -+ printk("kpatch-test: testing gcc .isra function name mangling\n"); - atomic_inc(&poll->event); - wake_up_interruptible(&poll->wait); - }
  53. Download patch test/integration/centos-7/gcc-constprop.patch

    --- 0.3.2-3.1/test/integration/centos-7/gcc-constprop.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/gcc-constprop.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,13 @@ +diff -Nupr src.orig/kernel/time/timekeeping.c src/kernel/time/timekeeping.c +--- src.orig/kernel/time/timekeeping.c 2017-09-22 15:27:21.602055778 -0400 ++++ src/kernel/time/timekeeping.c 2017-09-22 15:27:27.522080292 -0400 +@@ -877,6 +877,9 @@ void do_gettimeofday(struct timeval *tv) + { + struct timespec64 now; + ++ if (!tv) ++ return; ++ + getnstimeofday64(&now); + tv->tv_sec = now.tv_sec; + tv->tv_usec = now.tv_nsec/1000;
  54. Download patch kmod/Makefile

    --- 0.3.2-3.1/kmod/Makefile 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/kmod/Makefile 2017-12-21 05:02:48.000000000 +0000 @@ -1,4 +1,6 @@ include ../Makefile.inc +KPATCH_BUILD ?= /lib/modules/$(shell uname -r)/build +KERNELRELEASE := $(lastword $(subst /, , $(dir $(KPATCH_BUILD)))) all: clean ifeq ($(BUILDMOD),yes) @@ -7,9 +9,9 @@ endif install: ifeq ($(BUILDMOD),yes) - $(INSTALL) -d $(MODULESDIR)/$(shell uname -r) - $(INSTALL) -m 644 core/kpatch.ko $(MODULESDIR)/$(shell uname -r) - $(INSTALL) -m 644 core/Module.symvers $(MODULESDIR)/$(shell uname -r) + $(INSTALL) -d $(MODULESDIR)/$(KERNELRELEASE) + $(INSTALL) -m 644 core/kpatch.ko $(MODULESDIR)/$(KERNELRELEASE) + $(INSTALL) -m 644 core/Module.symvers $(MODULESDIR)/$(KERNELRELEASE) endif $(INSTALL) -d $(DATADIR)/patch $(INSTALL) -m 644 patch/* $(DATADIR)/patch
  55. Download patch test/integration/f22/gcc-mangled-3.patch

    --- 0.3.2-3.1/test/integration/f22/gcc-mangled-3.patch 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/f22/gcc-mangled-3.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -ensure that __cmpxchg_double_slab.isra.45 and -__cmpxchg_double_slab.isra.45.part.46 aren't correlated. -Index: src/mm/slub.c -=================================================================== ---- src.orig/mm/slub.c -+++ src/mm/slub.c -@@ -5320,6 +5320,9 @@ void get_slabinfo(struct kmem_cache *s, - int node; - struct kmem_cache_node *n; - -+ if (!jiffies) -+ printk("slabinfo\n"); -+ - for_each_kmem_cache_node(s, node, n) { - nr_slabs += node_nr_slabs(n); - nr_objs += node_nr_objs(n);
  56. Download patch test/integration/centos-7/meminfo-string.patch

    --- 0.3.2-3.1/test/integration/centos-7/meminfo-string.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/meminfo-string.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,12 @@ +diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c +--- src.orig/fs/proc/meminfo.c 2017-09-22 15:27:21.699056179 -0400 ++++ src/fs/proc/meminfo.c 2017-09-22 15:27:41.274137239 -0400 +@@ -99,7 +99,7 @@ static int meminfo_proc_show(struct seq_ + "Committed_AS: %8lu kB\n" + "VmallocTotal: %8lu kB\n" + "VmallocUsed: %8lu kB\n" +- "VmallocChunk: %8lu kB\n" ++ "VMALLOCCHUNK: %8lu kB\n" + #ifdef CONFIG_MEMORY_FAILURE + "HardwareCorrupted: %5lu kB\n" + #endif
  57. Download patch kpatch-build/kpatch-elf.h

    --- 0.3.2-3.1/kpatch-build/kpatch-elf.h 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/kpatch-build/kpatch-elf.h 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,164 @@ +/* + * kpatch-elf.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, + * 02110-1301, USA. + */ + +#ifndef _KPATCH_ELF_H_ +#define _KPATCH_ELF_H_ + +#include <gelf.h> +#include "list.h" +#include "log.h" + +#define KLP_SYM_PREFIX ".klp.sym." +#define KLP_RELASEC_PREFIX ".klp.rela." +#define KLP_ARCH_PREFIX ".klp.arch." +#define SHF_RELA_LIVEPATCH 0x00100000 +#define SHN_LIVEPATCH 0xff20 + +/******************* + * Data structures + * ****************/ +struct section; +struct symbol; +struct rela; + +enum status { + NEW, + CHANGED, + SAME +}; + +struct section { + struct list_head list; + struct section *twin; + GElf_Shdr sh; + Elf_Data *data; + char *name; + int index; + enum status status; + int include; + int ignore; + int grouped; + union { + struct { /* if (is_rela_section()) */ + struct section *base; + struct list_head relas; + }; + struct { /* else */ + struct section *rela; + struct symbol *secsym, *sym; + }; + }; +}; + +struct symbol { + struct list_head list; + struct symbol *twin; + struct section *sec; + GElf_Sym sym; + char *name; + int index; + unsigned char bind, type; + enum status status; + union { + int include; /* used in the patched elf */ + int strip; /* used in the output elf */ + }; + int has_func_profiling; +}; + +struct rela { + struct list_head list; + GElf_Rela rela; + struct symbol *sym; + unsigned int type; + int addend; + int offset; + char *string; +}; + +struct string { + struct list_head list; + char *name; +}; + +struct kpatch_elf { + Elf *elf; + struct list_head sections; + struct list_head symbols; + struct list_head strings; + int fd; +}; + +/******************* + * Helper functions + ******************/ +char *status_str(enum status status); +int is_rela_section(struct section *sec); +int is_text_section(struct section *sec); +int is_debug_section(struct section *sec); + +struct section *find_section_by_index(struct list_head *list, unsigned int index); +struct section *find_section_by_name(struct list_head *list, const char *name); +struct symbol *find_symbol_by_index(struct list_head *list, size_t index); +struct symbol *find_symbol_by_name(struct list_head *list, const char *name); +struct rela *find_rela_by_offset(struct section *relasec, unsigned int offset); + +#define ALLOC_LINK(_new, _list) \ +{ \ + (_new) = malloc(sizeof(*(_new))); \ + if (!(_new)) \ + ERROR("malloc"); \ + memset((_new), 0, sizeof(*(_new))); \ + INIT_LIST_HEAD(&(_new)->list); \ + list_add_tail(&(_new)->list, (_list)); \ +} + +int offset_of_string(struct list_head *list, char *name); + +#ifndef R_PPC64_ENTRY +#define R_PPC64_ENTRY 118 +#endif + +/************* + * Functions + * **********/ +void kpatch_create_rela_list(struct kpatch_elf *kelf, struct section *sec); +void kpatch_create_section_list(struct kpatch_elf *kelf); +void kpatch_create_symbol_list(struct kpatch_elf *kelf); +struct kpatch_elf *kpatch_elf_open(const char *name); +void kpatch_dump_kelf(struct kpatch_elf *kelf); + +int is_null_sym(struct symbol *sym); +int is_file_sym(struct symbol *sym); +int is_local_func_sym(struct symbol *sym); +int is_local_sym(struct symbol *sym); + +void print_strtab(char *buf, size_t size); +void kpatch_create_shstrtab(struct kpatch_elf *kelf); +void kpatch_create_strtab(struct kpatch_elf *kelf); +void kpatch_create_symtab(struct kpatch_elf *kelf); +struct section *create_section_pair(struct kpatch_elf *kelf, char *name, + int entsize, int nr); +void kpatch_remove_and_free_section(struct kpatch_elf *kelf, char *secname); +void kpatch_reindex_elements(struct kpatch_elf *kelf); +void kpatch_rebuild_rela_section_data(struct section *sec); +void kpatch_write_output_elf(struct kpatch_elf *kelf, Elf *elf, char *outfile); +void kpatch_elf_teardown(struct kpatch_elf *kelf); +void kpatch_elf_free(struct kpatch_elf *kelf); +#endif /* _KPATCH_ELF_H_ */
  58. Download patch test/integration/centos-7/tracepoints-section.patch

    --- 0.3.2-3.1/test/integration/centos-7/tracepoints-section.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/tracepoints-section.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,13 @@ +diff -Nupr src.orig/kernel/timer.c src/kernel/timer.c +--- src.orig/kernel/timer.c 2017-09-22 15:27:21.600055769 -0400 ++++ src/kernel/timer.c 2017-09-22 15:27:54.288191131 -0400 +@@ -1390,6 +1390,9 @@ static void run_timer_softirq(struct sof + { + struct tvec_base *base = __this_cpu_read(tvec_bases); + ++ if (!base) ++ printk("kpatch-test: testing __tracepoints section changes\n"); ++ + if (time_after_eq(jiffies, base->timer_jiffies)) + __run_timers(base); + }
  59. Download patch test/integration/centos-7/gcc-static-local-var-4.test

    --- 0.3.2-3.1/test/integration/centos-7/gcc-static-local-var-4.test 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/gcc-static-local-var-4.test 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,7 @@ +#!/bin/bash + +if $(nm kpatch-gcc-static-local-var-4.ko | grep -q free_ioctx); then + exit 1 +else + exit 0 +fi
  60. Download patch test/integration/centos-7/special-static.patch

    --- 0.3.2-3.1/test/integration/centos-7/special-static.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/special-static.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,22 @@ +diff -Nupr src.orig/kernel/fork.c src/kernel/fork.c +--- src.orig/kernel/fork.c 2017-09-22 15:27:21.600055769 -0400 ++++ src/kernel/fork.c 2017-09-22 15:27:53.052186012 -0400 +@@ -1129,10 +1129,18 @@ static void posix_cpu_timers_init_group( + INIT_LIST_HEAD(&sig->cpu_timers[2]); + } + ++void kpatch_foo(void) ++{ ++ if (!jiffies) ++ printk("kpatch copy signal\n"); ++} ++ + static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) + { + struct signal_struct *sig; + ++ kpatch_foo(); ++ + if (clone_flags & CLONE_THREAD) + return 0; +
  61. Download patch debian/patches/kmod-core-use-save_stack_trace_tsk-backport.patch
  62. Download patch debian/patches/series

    --- 0.3.2-3.1/debian/patches/series 2017-04-01 19:03:23.000000000 +0000 +++ 0.5.0-0ubuntu2/debian/patches/series 2019-02-18 08:39:39.000000000 +0000 @@ -1,4 +1,6 @@ kpatch-build-adjust-dirs.patch -kpatch-build-works-without-kpatch-kmod.patch -create-diff-object-fix-WARN-_ONCE-detection-on-newer.patch -kmod-core-use-save_stack_trace_tsk-backport.patch +use-debian-rules-for-ubuntu-builds.patch +ubuntu-kernel-variants.patch +kmod-fix-symbol-lookup-on-linux-4.19.patch +kpatch-build-fix-clean-target.patch +shellcheck.patch
  63. Download patch test/integration/centos-7/macro-hooks-LOADED.test

    --- 0.3.2-3.1/test/integration/centos-7/macro-hooks-LOADED.test 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/macro-hooks-LOADED.test 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,3 @@ +#!/bin/bash + +[[ $(cat /proc/sys/fs/aio-max-nr) = 262144 ]]
  64. Download patch kpatch-build/kpatch-gcc

    --- 0.3.2-3.1/kpatch-build/kpatch-gcc 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/kpatch-build/kpatch-gcc 2017-12-21 05:02:48.000000000 +0000 @@ -1,12 +1,14 @@ #!/bin/bash -set -x +if [[ ${KPATCH_GCC_DEBUG:-0} -ne 0 ]]; then + set -o xtrace +fi TOOLCHAINCMD="$1" shift -if [[ -z "$TEMPDIR" ]]; then - exec "$TOOLCHAINCMD" "$@" +if [[ -z "$KPATCH_GCC_TEMPDIR" ]]; then + exec "$TOOLCHAINCMD" "$@" fi declare -a args=("$@") @@ -14,8 +16,13 @@ declare -a args=("$@") if [[ "$TOOLCHAINCMD" = "gcc" ]] ; then while [ "$#" -gt 0 ]; do if [ "$1" = "-o" ]; then - obj=$2 - [[ $2 = */.tmp_*.o ]] && obj=${2/.tmp_/} + obj="$2" + + # skip copying the temporary .o files created by + # recordmcount.pl + [[ "$obj" = */.tmp_mc_*.o ]] && break; + + [[ "$obj" = */.tmp_*.o ]] && obj="${obj/.tmp_/}" case "$obj" in *.mod.o|\ *built-in.o|\ @@ -32,13 +39,15 @@ if [[ "$TOOLCHAINCMD" = "gcc" ]] ; then arch/x86/vdso/*|\ arch/x86/entry/vdso/*|\ drivers/firmware/efi/libstub/*|\ - .*.o) + arch/powerpc/kernel/prom_init.o|\ + .*.o|\ + */.lib_exports.o) break ;; *.o) - mkdir -p "$TEMPDIR/orig/$(dirname $obj)" - [[ -e $obj ]] && cp -f "$obj" "$TEMPDIR/orig/$obj" - echo "$obj" >> "$TEMPDIR/changed_objs" + mkdir -p "$KPATCH_GCC_TEMPDIR/orig/$(dirname "$obj")" + [[ -e "$obj" ]] && cp -f "$obj" "$KPATCH_GCC_TEMPDIR/orig/$obj" + echo "$obj" >> "$KPATCH_GCC_TEMPDIR/changed_objs" break ;; *) @@ -51,11 +60,15 @@ if [[ "$TOOLCHAINCMD" = "gcc" ]] ; then elif [[ "$TOOLCHAINCMD" = "ld" ]] ; then while [ "$#" -gt 0 ]; do if [ "$1" = "-o" ]; then - obj=$2 + obj="$2" case "$obj" in *.ko) - mkdir -p "$TEMPDIR/module/$(dirname $obj)" - cp -f "$obj" "$TEMPDIR/module/$obj" + mkdir -p "$KPATCH_GCC_TEMPDIR/module/$(dirname "$obj")" + cp -f "$obj" "$KPATCH_GCC_TEMPDIR/module/$obj" + break + ;; + .tmp_vmlinux*|vmlinux) + args+=(--warn-unresolved-symbols) break ;; *)
  65. Download patch debian/patches/use-debian-rules-for-ubuntu-builds.patch
  66. Download patch debian/patches/kpatch-build-fix-clean-target.patch

    --- 0.3.2-3.1/debian/patches/kpatch-build-fix-clean-target.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/debian/patches/kpatch-build-fix-clean-target.patch 2019-02-18 08:38:37.000000000 +0000 @@ -0,0 +1,17 @@ +From: Ben Hutchings <ben@decadent.org.uk> +Date: Mon, 07 Jan 2019 19:37:04 +0000 +Subject: kpatch-build: Fix clean target + +The clean target uses brace-expansion which is a bash extension not +supported by e.g. dash. Force use of bash for this target. + +--- +--- a/kpatch-build/Makefile ++++ b/kpatch-build/Makefile +@@ -43,5 +43,6 @@ uninstall: + $(RM) -R $(LIBEXECDIR) + $(RM) $(BINDIR)/kpatch-build + ++clean: SHELL = /bin/bash + clean: + $(RM) $(TARGETS) *.{o,d} insn/*.{o,d} gcc-plugins/*.{so,d}
  67. Download patch test/integration/f22/data-read-mostly.patch

    --- 0.3.2-3.1/test/integration/f22/data-read-mostly.patch 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/f22/data-read-mostly.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -Index: src/net/core/dev.c -=================================================================== ---- src.orig/net/core/dev.c -+++ src/net/core/dev.c -@@ -3609,6 +3609,7 @@ ncls: - case RX_HANDLER_PASS: - break; - default: -+ printk("BUG!\n"); - BUG(); - } - }
  68. Download patch kpatch/kpatch
  69. Download patch test/integration/f22/bug-table-section.patch

    --- 0.3.2-3.1/test/integration/f22/bug-table-section.patch 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/f22/bug-table-section.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -Index: src/fs/proc/proc_sysctl.c -=================================================================== ---- src.orig/fs/proc/proc_sysctl.c -+++ src/fs/proc/proc_sysctl.c -@@ -266,6 +266,8 @@ void sysctl_head_put(struct ctl_table_he - - static struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) - { -+ if (jiffies == 0) -+ printk("kpatch-test: testing __bug_table section changes\n"); - BUG_ON(!head); - spin_lock(&sysctl_lock); - if (!use_table(head))
  70. Download patch kmod/patch/kpatch.lds

    --- 0.3.2-3.1/kmod/patch/kpatch.lds 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/kmod/patch/kpatch.lds 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -__kpatch_funcs = ADDR(.kpatch.funcs); -__kpatch_funcs_end = ADDR(.kpatch.funcs) + SIZEOF(.kpatch.funcs); -__kpatch_dynrelas = ADDR(.kpatch.dynrelas); -__kpatch_dynrelas_end = ADDR(.kpatch.dynrelas) + SIZEOF(.kpatch.dynrelas); -__kpatch_checksum = ADDR(.kpatch.checksum); -SECTIONS -{ - .kpatch.hooks.load : { - __kpatch_hooks_load = . ; - *(.kpatch.hooks.load) - __kpatch_hooks_load_end = . ; - /* - * Pad the end of the section with zeros in case the section is empty. - * This prevents the kernel from discarding the section at module - * load time. __kpatch_hooks_load_end will still point to the end of - * the section before the padding. If the .kpatch.hooks.load section - * is empty, __kpatch_hooks_load equals __kpatch_hooks_load_end. - */ - QUAD(0); - } - .kpatch.hooks.unload : { - __kpatch_hooks_unload = . ; - *(.kpatch.hooks.unload) - __kpatch_hooks_unload_end = . ; - QUAD(0); - } - .kpatch.force : { - __kpatch_force_funcs = . ; - *(.kpatch.force) - __kpatch_force_funcs_end = . ; - QUAD(0); - } -}
  71. Download patch test/integration/f22/gcc-static-local-var-2.patch

    --- 0.3.2-3.1/test/integration/f22/gcc-static-local-var-2.patch 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/f22/gcc-static-local-var-2.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -Index: src/mm/mmap.c -=================================================================== ---- src.orig/mm/mmap.c -+++ src/mm/mmap.c -@@ -1493,6 +1493,7 @@ static inline int accountable_mapping(st - return (vm_flags & (VM_NORESERVE | VM_SHARED | VM_WRITE)) == VM_WRITE; - } - -+#include "kpatch-macros.h" - unsigned long mmap_region(struct file *file, unsigned long addr, - unsigned long len, vm_flags_t vm_flags, unsigned long pgoff) - { -@@ -1502,6 +1503,9 @@ unsigned long mmap_region(struct file *f - struct rb_node **rb_link, *rb_parent; - unsigned long charged = 0; - -+ if (!jiffies) -+ printk("kpatch mmap foo\n"); -+ - /* Check against address space limit. */ - if (!may_expand_vm(mm, len >> PAGE_SHIFT)) { - unsigned long nr_pages;
  72. Download patch test/integration/centos-7/meminfo-init-FAIL.patch

    --- 0.3.2-3.1/test/integration/centos-7/meminfo-init-FAIL.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/meminfo-init-FAIL.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,11 @@ +diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c +--- src.orig/fs/proc/meminfo.c 2017-09-22 15:27:21.699056179 -0400 ++++ src/fs/proc/meminfo.c 2017-09-22 15:27:40.130132502 -0400 +@@ -191,6 +191,7 @@ static const struct file_operations memi + + static int __init proc_meminfo_init(void) + { ++ printk("a\n"); + proc_create("meminfo", 0, NULL, &meminfo_proc_fops); + return 0; + }
  73. Download patch test/integration/f22/gcc-constprop.patch

    --- 0.3.2-3.1/test/integration/f22/gcc-constprop.patch 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/f22/gcc-constprop.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -ensure timekeeping_forward_now.constprop.8 and -timekeeping_forward_now.constprop.9 are correlated. -Index: src/kernel/time/timekeeping.c -=================================================================== ---- src.orig/kernel/time/timekeeping.c -+++ src/kernel/time/timekeeping.c -@@ -781,6 +781,9 @@ void do_gettimeofday(struct timeval *tv) - { - struct timespec64 now; - -+ if (!tv) -+ return; -+ - getnstimeofday64(&now); - tv->tv_sec = now.tv_sec; - tv->tv_usec = now.tv_nsec/1000;
  74. Download patch kmod/patch/kpatch.lds.S

    --- 0.3.2-3.1/kmod/patch/kpatch.lds.S 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/kmod/patch/kpatch.lds.S 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,37 @@ +__kpatch_funcs = ADDR(.kpatch.funcs); +__kpatch_funcs_end = ADDR(.kpatch.funcs) + SIZEOF(.kpatch.funcs); + +#ifdef __KPATCH_MODULE__ +__kpatch_dynrelas = ADDR(.kpatch.dynrelas); +__kpatch_dynrelas_end = ADDR(.kpatch.dynrelas) + SIZEOF(.kpatch.dynrelas); +__kpatch_checksum = ADDR(.kpatch.checksum); +#endif + +SECTIONS +{ + .kpatch.hooks.load : { + __kpatch_hooks_load = . ; + *(.kpatch.hooks.load) + __kpatch_hooks_load_end = . ; + /* + * Pad the end of the section with zeros in case the section is empty. + * This prevents the kernel from discarding the section at module + * load time. __kpatch_hooks_load_end will still point to the end of + * the section before the padding. If the .kpatch.hooks.load section + * is empty, __kpatch_hooks_load equals __kpatch_hooks_load_end. + */ + QUAD(0); + } + .kpatch.hooks.unload : { + __kpatch_hooks_unload = . ; + *(.kpatch.hooks.unload) + __kpatch_hooks_unload_end = . ; + QUAD(0); + } + .kpatch.force : { + __kpatch_force_funcs = . ; + *(.kpatch.force) + __kpatch_force_funcs_end = . ; + QUAD(0); + } +}
  75. Download patch test/integration/f22/gcc-static-local-var-3.patch

    --- 0.3.2-3.1/test/integration/f22/gcc-static-local-var-3.patch 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/f22/gcc-static-local-var-3.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -Index: src/kernel/reboot.c -=================================================================== ---- src.orig/kernel/reboot.c -+++ src/kernel/reboot.c -@@ -285,8 +285,15 @@ SYSCALL_DEFINE4(reboot, int, magic1, int - return ret; - } - -+void kpatch_bar(void) -+{ -+ if (!jiffies) -+ printk("kpatch_foo\n"); -+} -+ - static void deferred_cad(struct work_struct *dummy) - { -+ kpatch_bar(); - kernel_restart(NULL); - } -
  76. Download patch test/integration/centos-7/meminfo-string-LOADED.test

    --- 0.3.2-3.1/test/integration/centos-7/meminfo-string-LOADED.test 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/meminfo-string-LOADED.test 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,3 @@ +#!/bin/bash + +grep VMALLOCCHUNK /proc/meminfo
  77. Download patch contrib/kpatch.spec

    --- 0.3.2-3.1/contrib/kpatch.spec 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/contrib/kpatch.spec 2017-12-21 05:02:48.000000000 +0000 @@ -1,6 +1,6 @@ Name: kpatch Summary: Dynamic kernel patching -Version: 0.3.2 +Version: 0.4.0 License: GPLv2 Group: System Environment/Kernel URL: http://github.com/dynup/kpatch
  78. Download patch test/integration/centos-7/shadow-newpid.patch

    --- 0.3.2-3.1/test/integration/centos-7/shadow-newpid.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/shadow-newpid.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,69 @@ +diff -Nupr src.orig/fs/proc/array.c src/fs/proc/array.c +--- src.orig/fs/proc/array.c 2017-09-22 16:52:10.597110096 -0400 ++++ src/fs/proc/array.c 2017-09-22 16:59:40.799972178 -0400 +@@ -359,13 +359,20 @@ static inline void task_seccomp(struct s + #endif + } + ++#include "kpatch.h" + static inline void task_context_switch_counts(struct seq_file *m, + struct task_struct *p) + { ++ int *newpid; ++ + seq_printf(m, "voluntary_ctxt_switches:\t%lu\n" + "nonvoluntary_ctxt_switches:\t%lu\n", + p->nvcsw, + p->nivcsw); ++ ++ newpid = kpatch_shadow_get(p, "newpid"); ++ if (newpid) ++ seq_printf(m, "newpid:\t%d\n", *newpid); + } + + static void task_cpus_allowed(struct seq_file *m, struct task_struct *task) +diff -Nupr src.orig/kernel/exit.c src/kernel/exit.c +--- src.orig/kernel/exit.c 2017-09-22 16:52:10.506109720 -0400 ++++ src/kernel/exit.c 2017-09-22 16:59:40.799972178 -0400 +@@ -715,6 +715,7 @@ static void check_stack_usage(void) + static inline void check_stack_usage(void) {} + #endif + ++#include "kpatch.h" + void do_exit(long code) + { + struct task_struct *tsk = current; +@@ -812,6 +813,8 @@ void do_exit(long code) + check_stack_usage(); + exit_thread(); + ++ kpatch_shadow_free(tsk, "newpid"); ++ + /* + * Flush inherited counters to the parent - before the parent + * gets woken up by child-exit notifications. +diff -Nupr src.orig/kernel/fork.c src/kernel/fork.c +--- src.orig/kernel/fork.c 2017-09-22 16:52:10.504109711 -0400 ++++ src/kernel/fork.c 2017-09-22 17:00:44.938237460 -0400 +@@ -1700,6 +1700,7 @@ struct task_struct *fork_idle(int cpu) + * It copies the process, and if successful kick-starts + * it and waits for it to finish using the VM if required. + */ ++#include "kpatch.h" + long do_fork(unsigned long clone_flags, + unsigned long stack_start, + unsigned long stack_size, +@@ -1737,6 +1738,13 @@ long do_fork(unsigned long clone_flags, + if (!IS_ERR(p)) { + struct completion vfork; + struct pid *pid; ++ int *newpid; ++ static int ctr = 0; ++ ++ newpid = kpatch_shadow_alloc(p, "newpid", sizeof(*newpid), ++ GFP_KERNEL); ++ if (newpid) ++ *newpid = ctr++; + + trace_sched_process_fork(current, p); +
  79. Download patch Makefile

    --- 0.3.2-3.1/Makefile 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/Makefile 2017-12-21 05:02:48.000000000 +0000 @@ -6,6 +6,7 @@ INSTALL_DIRS = $(SUBDIRS:%=install-%) UNINSTALL_DIRS = $(SUBDIRS:%=uninstall-%) CLEAN_DIRS = $(SUBDIRS:%=clean-%) +.PHONY: all install uninstall clean check .PHONY: $(SUBDIRS) $(BUILD_DIRS) $(INSTALL_DIRS) $(CLEAN_DIRS) @@ -24,3 +25,6 @@ $(UNINSTALL_DIRS): clean: $(CLEAN_DIRS) $(CLEAN_DIRS): $(MAKE) -C $(@:clean-%=%) clean + +check: + shellcheck kpatch/kpatch kpatch-build/kpatch-build kpatch-build/kpatch-gcc
  80. Download patch test/integration/f22/gcc-static-local-var-4.patch

    --- 0.3.2-3.1/test/integration/f22/gcc-static-local-var-4.patch 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/f22/gcc-static-local-var-4.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -Index: src/fs/aio.c -=================================================================== ---- src.orig/fs/aio.c -+++ src/fs/aio.c -@@ -229,9 +229,16 @@ static int __init aio_setup(void) - } - __initcall(aio_setup); - -+void kpatch_aio_foo(void) -+{ -+ if (!jiffies) -+ printk("kpatch aio foo\n"); -+} -+ - static void put_aio_ring_file(struct kioctx *ctx) - { - struct file *aio_ring_file = ctx->aio_ring_file; -+ kpatch_aio_foo(); - if (aio_ring_file) { - truncate_setsize(aio_ring_file->f_inode, 0); -
  81. Download patch debian/post-dkms.sh

    --- 0.3.2-3.1/debian/post-dkms.sh 2016-02-18 16:46:39.000000000 +0000 +++ 0.5.0-0ubuntu2/debian/post-dkms.sh 2016-07-27 23:12:29.000000000 +0000 @@ -1,4 +1,5 @@ #!/bin/bash module_version=$1 kernelver=$2 +mkdir -p /lib/modules/$kernelver/updates/dkms/ cp /var/lib/dkms/kpatch/$module_version/build/kmod/core/Module.symvers /lib/modules/$kernelver/updates/dkms/kpatch.Module.symvers
  82. Download patch debian/patches/shellcheck.patch

    --- 0.3.2-3.1/debian/patches/shellcheck.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/debian/patches/shellcheck.patch 2019-02-18 08:39:39.000000000 +0000 @@ -0,0 +1,42 @@ +Description: implement more shellcheck things +Author: Dimitri John Ledkov <xnox@ubuntu.com> + + +--- kpatch-0.5.0.orig/kpatch-build/kpatch-build ++++ kpatch-0.5.0/kpatch-build/kpatch-build +@@ -167,7 +167,7 @@ ubuntu_build_external() { + + # $1 >= $2 + version_gte() { +- [ "$1" = "$(echo -e "$1\n$2" | sort -rV | head -n1)" ] ++ [ "$1" = "$(echo -e "$1\\n$2" | sort -rV | head -n1)" ] + } + + is_rhel() { +@@ -323,7 +323,7 @@ find_parent_obj() { + pdir="${absdir#$pwddir/}" + file="$(basename "$1")" + grepname="${1%.o}" +- grepname="$grepname\.o" ++ grepname="$grepname\\.o" + if [[ "$DEEP_FIND" -eq 1 ]]; then + num=0 + if [[ -n "$last_deep_find" ]]; then +@@ -724,7 +724,7 @@ if [[ $DISTRO = ubuntu ]]; then + fakeroot debian/rules clean 2>&1 | logger || die + MAKEFLAGS="--no-print-directory" debian/rules -j "$CPUS" \ + "build-$FLAVOR" build_image=vmlinux builddir="$TEMPDIR" \ +- enable_zfs=false CROSS_COMPILE="$TOOLSDIR/kpatch-gcc\ " 2>&1 | logger \ ++ enable_zfs=false CROSS_COMPILE="$TOOLSDIR/kpatch-gcc\\ " 2>&1 | logger \ + || die + ubuntu_build_external spl --with-linux="$SRCDIR" \ + --with-linux-obj="$TEMPDIR/build-$FLAVOR" | logger || die +@@ -752,7 +752,7 @@ if [[ $DISTRO = ubuntu ]]; then + rm -f "debian/stamps/stamp-build-$FLAVOR" + MAKEFLAGS="--no-print-directory" debian/rules -j "$CPUS" \ + "build-$FLAVOR" build_image=vmlinux \ +- CROSS_COMPILE="$TOOLSDIR/kpatch-gcc\ " enable_zfs=false \ ++ CROSS_COMPILE="$TOOLSDIR/kpatch-gcc\\ " enable_zfs=false \ + LDFLAGS_vmlinux="--warn-unresolved-symbols" \ + KBUILD_MODPOST_WARN=1 builddir="$TEMPDIR" 2>&1 | logger || die + else
  83. Download patch test/integration/centos-7/meminfo-cmdline-rebuild-SLOW.patch

    --- 0.3.2-3.1/test/integration/centos-7/meminfo-cmdline-rebuild-SLOW.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/meminfo-cmdline-rebuild-SLOW.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,35 @@ +diff -Nupr src.orig/fs/proc/cmdline.c src/fs/proc/cmdline.c +--- src.orig/fs/proc/cmdline.c 2017-09-22 15:27:21.698056175 -0400 ++++ src/fs/proc/cmdline.c 2017-09-22 15:27:37.842123028 -0400 +@@ -5,7 +5,7 @@ + + static int cmdline_proc_show(struct seq_file *m, void *v) + { +- seq_printf(m, "%s\n", saved_command_line); ++ seq_printf(m, "%s kpatch=1\n", saved_command_line); + return 0; + } + +diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c +--- src.orig/fs/proc/meminfo.c 2017-09-22 15:27:21.699056179 -0400 ++++ src/fs/proc/meminfo.c 2017-09-22 15:27:37.843123032 -0400 +@@ -99,7 +99,7 @@ static int meminfo_proc_show(struct seq_ + "Committed_AS: %8lu kB\n" + "VmallocTotal: %8lu kB\n" + "VmallocUsed: %8lu kB\n" +- "VmallocChunk: %8lu kB\n" ++ "VMALLOCCHUNK: %8lu kB\n" + #ifdef CONFIG_MEMORY_FAILURE + "HardwareCorrupted: %5lu kB\n" + #endif +diff -Nupr src.orig/include/linux/kernel.h src/include/linux/kernel.h +--- src.orig/include/linux/kernel.h 2017-09-22 15:27:20.379050713 -0400 ++++ src/include/linux/kernel.h 2017-09-22 15:27:37.843123032 -0400 +@@ -2,6 +2,7 @@ + #define _LINUX_KERNEL_H + + ++ + #include <stdarg.h> + #include <linux/linkage.h> + #include <linux/stddef.h>
  84. Download patch test/integration/centos-7/meminfo-cmdline-rebuild-SLOW-LOADED.test

    --- 0.3.2-3.1/test/integration/centos-7/meminfo-cmdline-rebuild-SLOW-LOADED.test 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/meminfo-cmdline-rebuild-SLOW-LOADED.test 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,3 @@ +#!/bin/bash + +grep VMALLOCCHUNK /proc/meminfo && grep kpatch=1 /proc/cmdline
  85. Download patch test/integration/centos-7/gcc-isra.patch

    --- 0.3.2-3.1/test/integration/centos-7/gcc-isra.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/gcc-isra.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,11 @@ +diff -Nupr src.orig/fs/proc/proc_sysctl.c src/fs/proc/proc_sysctl.c +--- src.orig/fs/proc/proc_sysctl.c 2017-09-22 15:27:21.698056175 -0400 ++++ src/fs/proc/proc_sysctl.c 2017-09-22 15:27:28.670085046 -0400 +@@ -24,6 +24,7 @@ void proc_sys_poll_notify(struct ctl_tab + if (!poll) + return; + ++ printk("kpatch-test: testing gcc .isra function name mangling\n"); + atomic_inc(&poll->event); + wake_up_interruptible(&poll->wait); + }
  86. Download patch test/integration/centos-7/module-call-external.patch

    --- 0.3.2-3.1/test/integration/centos-7/module-call-external.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/module-call-external.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,33 @@ +diff -Nupr src.orig/fs/nfsd/export.c src/fs/nfsd/export.c +--- src.orig/fs/nfsd/export.c 2017-09-22 15:27:21.705056204 -0400 ++++ src/fs/nfsd/export.c 2017-09-22 15:27:42.411141948 -0400 +@@ -1184,6 +1184,8 @@ static void exp_flags(struct seq_file *m + } + } + ++extern char *kpatch_string(void); ++ + static int e_show(struct seq_file *m, void *p) + { + struct cache_head *cp = p; +@@ -1193,6 +1195,7 @@ static int e_show(struct seq_file *m, vo + if (p == SEQ_START_TOKEN) { + seq_puts(m, "# Version 1.1\n"); + seq_puts(m, "# Path Client(Flags) # IPs\n"); ++ seq_puts(m, kpatch_string()); + return 0; + } + +diff -Nupr src.orig/net/netlink/af_netlink.c src/net/netlink/af_netlink.c +--- src.orig/net/netlink/af_netlink.c 2017-09-22 15:27:21.754056407 -0400 ++++ src/net/netlink/af_netlink.c 2017-09-22 15:27:42.412141952 -0400 +@@ -3260,4 +3260,9 @@ panic: + panic("netlink_init: Cannot allocate nl_table\n"); + } + ++char *kpatch_string(void) ++{ ++ return "# kpatch\n"; ++} ++ + core_initcall(netlink_proto_init);
  87. Download patch debian/patches/create-diff-object-fix-WARN-_ONCE-detection-on-newer.patch

    --- 0.3.2-3.1/debian/patches/create-diff-object-fix-WARN-_ONCE-detection-on-newer.patch 2016-07-27 10:27:11.000000000 +0000 +++ 0.5.0-0ubuntu2/debian/patches/create-diff-object-fix-WARN-_ONCE-detection-on-newer.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -From 6b03bc8ec08106fd9070885c9fbd1fcb2bb7cb39 Mon Sep 17 00:00:00 2001 -From: Josh Poimboeuf <jpoimboe@redhat.com> -Date: Wed, 13 Jul 2016 16:44:14 -0500 -Subject: [PATCH] create-diff-object: fix WARN*_ONCE detection on newer kernels - -This fixes the detection of WARN_ON_ONCE, WARN_ONCE, and WARN_TAINT_ONCE -on Linux 4.6 and newer. - -The signature for those macros changed with upstream Linux commit -dfbf2897d004 ("bug: set warn variable before calling WARN()"). - -Fixes #602. ---- - kpatch-build/create-diff-object.c | 29 +++++++++++++++-------------- - 1 file changed, 15 insertions(+), 14 deletions(-) - ---- a/kpatch-build/create-diff-object.c -+++ b/kpatch-build/create-diff-object.c -@@ -690,22 +690,21 @@ - * Warning: Hackery lies herein. It's hopefully justified by the fact that - * this issue is very common. - * -- * base object: -- * -- * be 5e 04 00 00 mov $0x45e,%esi -- * 48 c7 c7 ff 5a a1 81 mov $0xffffffff81a15aff,%rdi -- * e8 26 13 08 00 callq ffffffff8108d0d0 <warn_slowpath_fmt> -- * -- * patched object: -- * -- * be 5e 04 00 00 mov $0x45f,%esi -- * 48 c7 c7 ff 5a a1 81 mov $0xffffffff81a15aff,%rdi -- * e8 26 13 08 00 callq ffffffff8108d0d0 <warn_slowpath_fmt> -- * -- * The above is the most common case. The pattern which applies to all cases -- * is an immediate move of the line number to %esi followed by zero or more -- * relas to a string section followed by a rela to warn_slowpath_*. -+ * Example: - * -+ * 938: be 70 00 00 00 mov $0x70,%esi -+ * 93d: 48 c7 c7 00 00 00 00 mov $0x0,%rdi -+ * 940: R_X86_64_32S .rodata.tcp_conn_request.str1.8+0x88 -+ * 944: c6 05 00 00 00 00 01 movb $0x1,0x0(%rip) # 94b <tcp_conn_request+0x94b> -+ * 946: R_X86_64_PC32 .data.unlikely-0x1 -+ * 94b: e8 00 00 00 00 callq 950 <tcp_conn_request+0x950> -+ * 94c: R_X86_64_PC32 warn_slowpath_null-0x4 -+ * -+ * The pattern which applies to all cases: -+ * 1) immediate move of the line number to %esi -+ * 2) (optional) string section rela -+ * 3) (optional) __warned.xxxxx static local rela -+ * 4) warn_slowpath_* rela - */ - static int kpatch_warn_only_change(struct section *sec) - { -@@ -759,6 +758,8 @@ - continue; - if (rela->string) - continue; -+ if (!strncmp(rela->sym->name, "__warned.", 9)) -+ continue; - if (!strncmp(rela->sym->name, "warn_slowpath_", 14)) { - found = 1; - break;
  88. Download patch test/integration/f22/cmdline-string.patch

    --- 0.3.2-3.1/test/integration/f22/cmdline-string.patch 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/f22/cmdline-string.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -Index: src/fs/proc/cmdline.c -=================================================================== ---- src.orig/fs/proc/cmdline.c -+++ src/fs/proc/cmdline.c -@@ -5,7 +5,7 @@ - - static int cmdline_proc_show(struct seq_file *m, void *v) - { -- seq_printf(m, "%s\n", saved_command_line); -+ seq_printf(m, "%s kpatch=1\n", saved_command_line); - return 0; - } -
  89. Download patch Makefile.inc

    --- 0.3.2-3.1/Makefile.inc 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/Makefile.inc 2017-12-21 05:02:48.000000000 +0000 @@ -3,6 +3,8 @@ CC = gcc INSTALL = /usr/bin/install +ARCH = $(shell uname -m) + PREFIX ?= /usr/local LIBDIR ?= lib LIBEXEC ?= libexec @@ -13,7 +15,11 @@ LIBEXECDIR = $(DESTDIR)$(PREFIX)/$(LIBEX DATADIR = $(DESTDIR)$(PREFIX)/share/kpatch MANDIR = $(DESTDIR)$(PREFIX)/share/man/man1 SYSTEMDDIR = $(DESTDIR)$(PREFIX)/lib/systemd/system -BUILDMOD ?= yes + +# The core module is only supported on x86_64 +ifeq ($(ARCH),x86_64) +BUILDMOD ?= yes +endif .PHONY: all install clean .DEFAULT: all
  90. Download patch kpatch-build/gcc-plugins/ppc64le-plugin.c

    --- 0.3.2-3.1/kpatch-build/gcc-plugins/ppc64le-plugin.c 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/kpatch-build/gcc-plugins/ppc64le-plugin.c 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,86 @@ +#include "gcc-common.h" +#include <error.h> + +#define PLUGIN_NAME "ppc64le-plugin" + +int plugin_is_GPL_compatible; + +struct plugin_info plugin_info = { + .version = "1", + .help = PLUGIN_NAME ": insert nops after local calls\n", +}; + +static unsigned int ppc64le_plugin_execute(void) +{ + rtx_insn *insn; + int code; + const char *name; + static int nonlocal_code = -1, local_code = -1, + value_nonlocal_code = -1, value_local_code = -1; + static bool initialized = false; + + if (initialized) + goto found; + + /* Find the rs6000.md code numbers for local and non-local calls */ + initialized = true; + for (code = 0; code < 1000; code++) { + name = get_insn_name(code); + if (!name) + continue; + + if (!strcmp(name , "*call_local_aixdi")) + local_code = code; + else if (!strcmp(name , "*call_nonlocal_aixdi")) + nonlocal_code = code; + else if (!strcmp(name, "*call_value_local_aixdi")) + value_local_code = code; + else if (!strcmp(name, "*call_value_nonlocal_aixdi")) + value_nonlocal_code = code; + + if (nonlocal_code != -1 && local_code != -1 && + value_nonlocal_code != -1 && value_local_code != -1) + goto found; + } + +found: + if (nonlocal_code == -1 || local_code == -1 || + value_nonlocal_code == -1 || value_local_code == -1) { + fprintf(stderr, PLUGIN_NAME ": can't find call instruction codes"); + return 1; + } + + /* Convert local calls to non-local */ + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) { + if (GET_CODE(insn) == CALL_INSN) { + if (INSN_CODE(insn) == local_code) + INSN_CODE(insn) = nonlocal_code; + else if (INSN_CODE(insn) == value_local_code) + INSN_CODE(insn) = value_nonlocal_code; + } + } + + return 0; +} + +#define PASS_NAME ppc64le_plugin +#define NO_GATE +#include "gcc-generate-rtl-pass.h" + +int plugin_init(struct plugin_name_args *plugin_info, + struct plugin_gcc_version *version) +{ + const char * const plugin_name = plugin_info->base_name; + + PASS_INFO(ppc64le_plugin, "dwarf2", 1, PASS_POS_INSERT_BEFORE); + + if (!plugin_default_version_check(version, &gcc_version)) + error(1, 0, PLUGIN_NAME ": incompatible gcc/plugin versions"); + + register_callback(plugin_name, PLUGIN_INFO, NULL, &plugin_info); + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, + &ppc64le_plugin_pass_info); + + return 0; +} +
  91. Download patch kmod/patch/livepatch-patch-hook.c

    --- 0.3.2-3.1/kmod/patch/livepatch-patch-hook.c 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/kmod/patch/livepatch-patch-hook.c 2017-12-21 05:02:48.000000000 +0000 @@ -25,11 +25,33 @@ #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 + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0) || \ + defined(RHEL_RELEASE_CODE) +#define HAVE_ELF_RELOCS +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) && \ + UTS_UBUNTU_RELEASE_ABI >= 7) || \ + defined(RHEL_RELEASE_CODE) +#define HAVE_SYMPOS +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) || \ + defined(RHEL_RELEASE_CODE) +#define HAVE_IMMEDIATE +#endif + /* * There are quite a few similar structures at play in this file: * - livepatch.h structs prefixed with klp_* @@ -78,7 +100,9 @@ static struct patch_object *patch_alloc_ if (!object) return NULL; INIT_LIST_HEAD(&object->funcs); +#ifndef HAVE_ELF_RELOCS INIT_LIST_HEAD(&object->relocs); +#endif if (strcmp(name, "vmlinux")) object->name = name; list_add(&object->list, &patch_objects); @@ -118,6 +142,7 @@ static int patch_add_func_to_object(stru return 0; } +#ifndef HAVE_ELF_RELOCS static int patch_add_reloc_to_object(struct kpatch_patch_dynrela *kdynrela) { struct patch_reloc *reloc; @@ -138,11 +163,14 @@ static int patch_add_reloc_to_object(str object->relocs_nr++; return 0; } +#endif static void patch_free_scaffold(void) { struct patch_func *func, *safefunc; - struct patch_reloc *reloc, *safereloc; struct patch_object *object, *safeobject; +#ifndef HAVE_ELF_RELOCS + struct patch_reloc *reloc, *safereloc; +#endif list_for_each_entry_safe(object, safeobject, &patch_objects, list) { list_for_each_entry_safe(func, safefunc, @@ -150,11 +178,13 @@ static void patch_free_scaffold(void) { list_del(&func->list); kfree(func); } +#ifndef HAVE_ELF_RELOCS list_for_each_entry_safe(reloc, safereloc, &object->relocs, list) { list_del(&reloc->list); kfree(reloc); } +#endif list_del(&object->list); kfree(object); } @@ -168,8 +198,10 @@ static void patch_free_livepatch(struct for (object = patch->objs; object && object->funcs; object++) { if (object->funcs) kfree(object->funcs); +#ifndef HAVE_ELF_RELOCS if (object->relocs) kfree(object->relocs); +#endif } if (patch->objs) kfree(patch->objs); @@ -178,19 +210,23 @@ static void patch_free_livepatch(struct } extern struct kpatch_patch_func __kpatch_funcs[], __kpatch_funcs_end[]; +#ifndef HAVE_ELF_RELOCS extern struct kpatch_patch_dynrela __kpatch_dynrelas[], __kpatch_dynrelas_end[]; +#endif static int __init patch_init(void) { struct kpatch_patch_func *kfunc; - struct kpatch_patch_dynrela *kdynrela; struct klp_object *lobjects, *lobject; struct klp_func *lfuncs, *lfunc; - struct klp_reloc *lrelocs, *lreloc; struct patch_object *object; struct patch_func *func; - struct patch_reloc *reloc; int ret = 0, i, j; +#ifndef HAVE_ELF_RELOCS + struct kpatch_patch_dynrela *kdynrela; + struct patch_reloc *reloc; + struct klp_reloc *lrelocs, *lreloc; +#endif /* organize functions and relocs by object in scaffold */ for (kfunc = __kpatch_funcs; @@ -201,6 +237,7 @@ static int __init patch_init(void) goto out; } +#ifndef HAVE_ELF_RELOCS for (kdynrela = __kpatch_dynrelas; kdynrela != __kpatch_dynrelas_end; kdynrela++) { @@ -208,6 +245,7 @@ static int __init patch_init(void) if (ret) goto out; } +#endif /* past this point, only possible return code is -ENOMEM */ ret = -ENOMEM; @@ -223,6 +261,9 @@ static int __init patch_init(void) goto out; lpatch->mod = THIS_MODULE; lpatch->objs = lobjects; +#if defined(__powerpc__) && defined(HAVE_IMMEDIATE) + lpatch->immediate = true; +#endif i = 0; list_for_each_entry(object, &patch_objects, list) { @@ -238,7 +279,7 @@ 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) +#ifdef HAVE_SYMPOS lfunc->old_sympos = func->kfunc->sympos; #else lfunc->old_addr = func->kfunc->old_addr; @@ -246,6 +287,7 @@ static int __init patch_init(void) j++; } +#ifndef HAVE_ELF_RELOCS lrelocs = kzalloc(sizeof(struct klp_reloc) * (object->relocs_nr+1), GFP_KERNEL); if (!lrelocs) @@ -255,17 +297,18 @@ 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) +#ifdef HAVE_SYMPOS lreloc->sympos = reloc->kdynrela->sympos; #else lreloc->val = reloc->kdynrela->src; -#endif +#endif /* HAVE_SYMPOS */ lreloc->type = reloc->kdynrela->type; lreloc->name = reloc->kdynrela->name; lreloc->addend = reloc->kdynrela->addend; lreloc->external = reloc->kdynrela->external; j++; } +#endif /* HAVE_ELF_RELOCS */ i++; } @@ -304,3 +347,4 @@ static void __exit patch_exit(void) module_init(patch_init); module_exit(patch_exit); MODULE_LICENSE("GPL"); +MODULE_INFO(livepatch, "Y");
  92. Download patch test/integration/f22/data-new-LOADED.test

    --- 0.3.2-3.1/test/integration/f22/data-new-LOADED.test 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/f22/data-new-LOADED.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -#!/bin/bash - -grep "kpatch: 5" /proc/meminfo
  93. Download patch kmod/core/kpatch.h

    --- 0.3.2-3.1/kmod/core/kpatch.h 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/kmod/core/kpatch.h 2017-12-21 05:02:48.000000000 +0000 @@ -38,6 +38,7 @@ struct kpatch_func { unsigned long new_size; unsigned long old_addr; unsigned long old_size; + unsigned long sympos; const char *name; struct list_head list; int force; @@ -45,12 +46,14 @@ struct kpatch_func { /* private */ struct hlist_node node; enum kpatch_op op; + struct kobject kobj; }; struct kpatch_dynrela { unsigned long dest; unsigned long src; unsigned long type; + unsigned long sympos; const char *name; int addend; int external; @@ -72,6 +75,7 @@ struct kpatch_object { /* private */ struct module *mod; + struct kobject kobj; }; struct kpatch_module { @@ -84,9 +88,10 @@ struct kpatch_module { /* private */ struct list_head list; + struct kobject kobj; }; -extern struct kobject *kpatch_patches_kobj; +extern struct kobject *kpatch_root_kobj; extern int kpatch_register(struct kpatch_module *kpmod, bool replace); extern int kpatch_unregister(struct kpatch_module *kpmod);
  94. Download patch test/integration/centos-7/meminfo-init2-FAIL.patch

    --- 0.3.2-3.1/test/integration/centos-7/meminfo-init2-FAIL.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/meminfo-init2-FAIL.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,19 @@ +diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c +--- src.orig/fs/proc/meminfo.c 2017-09-22 15:27:21.699056179 -0400 ++++ src/fs/proc/meminfo.c 2017-09-22 15:27:38.972127707 -0400 +@@ -30,6 +30,7 @@ static int meminfo_proc_show(struct seq_ + unsigned long pages[NR_LRU_LISTS]; + int lru; + ++ printk("a\n"); + /* + * display in kilobytes. + */ +@@ -191,6 +192,7 @@ static const struct file_operations memi + + static int __init proc_meminfo_init(void) + { ++ printk("a\n"); + proc_create("meminfo", 0, NULL, &meminfo_proc_fops); + return 0; + }
  95. Download patch test/integration/f22/data-new.patch

    --- 0.3.2-3.1/test/integration/f22/data-new.patch 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/f22/data-new.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -Index: src/fs/proc/meminfo.c -=================================================================== ---- src.orig/fs/proc/meminfo.c -+++ src/fs/proc/meminfo.c -@@ -20,6 +20,8 @@ void __attribute__((weak)) arch_report_m - { - } - -+static int foo = 5; -+ - static int meminfo_proc_show(struct seq_file *m, void *v) - { - struct sysinfo i; -@@ -138,6 +140,7 @@ static int meminfo_proc_show(struct seq_ - #ifdef CONFIG_TRANSPARENT_HUGEPAGE - "AnonHugePages: %8lu kB\n" - #endif -+ "kpatch: %d" - , - K(i.totalram), - K(i.freeram), -@@ -193,6 +196,7 @@ static int meminfo_proc_show(struct seq_ - ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) * - HPAGE_PMD_NR) - #endif -+ ,foo - ); - - hugetlb_report_meminfo(m);
  96. Download patch test/integration/centos-7/fixup-section.patch

    --- 0.3.2-3.1/test/integration/centos-7/fixup-section.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/fixup-section.patch 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,12 @@ +diff -Nupr src.orig/fs/readdir.c src/fs/readdir.c +--- src.orig/fs/readdir.c 2017-09-22 15:27:21.658056010 -0400 ++++ src/fs/readdir.c 2017-09-22 15:27:26.378075555 -0400 +@@ -166,6 +166,8 @@ static int filldir(void * __buf, const c + goto efault; + } + dirent = buf->current_dir; ++ if (dirent->d_ino == 12345678) ++ printk("kpatch-test: testing .fixup section changes\n"); + if (__put_user(d_ino, &dirent->d_ino)) + goto efault; + if (__put_user(reclen, &dirent->d_reclen))
  97. Download patch debian/patches/ubuntu-kernel-variants.patch

    --- 0.3.2-3.1/debian/patches/ubuntu-kernel-variants.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/debian/patches/ubuntu-kernel-variants.patch 2018-04-12 01:41:51.000000000 +0000 @@ -0,0 +1,109 @@ +Description: Support Ubuntu kernel variants (lowlatency) + Update the kpatch-build program so that it will build non-generic ubuntu + kernels (i.e. lowlatency). The flavor is determined from the running + kernel, or from the vmlinux specified by the user. + +Author: Benjamin M Romer <benjamin.romer@canonical.com> +Last-Update: 2018-02-07 + +--- a/kpatch-build/kpatch-build ++++ b/kpatch-build/kpatch-build +@@ -49,6 +49,7 @@ + DEBUG=0 + SKIPCLEANUP=0 + SKIPGCCCHECK=0 ++FLAVOR=$(uname -r | cut -d - -f 3) + ARCH_KCFLAGS="" + declare -a PATCH_LIST + APPLIED_PATCHES=0 +@@ -151,8 +152,8 @@ + TARGET=$1 + EXTDIR="$TEMPDIR/build-generic/" + shift +- mkdir -p "$TEMPDIR/build-generic/$TARGET" +- cd "$TEMPDIR/build-generic/$TARGET" || die ++ mkdir -p "$TEMPDIR/build-$FLAVOR/$TARGET" ++ cd "$TEMPDIR/build-$FLAVOR/$TARGET" || die + if [ ! -e Makefile ]; then + bash "$SRCDIR/$TARGET/configure" "$@" 2>&1 | logger || die + make "-j$CPUS" EXTDIR="$EXTDIR" CROSS_COMPILE="$TOOLSDIR/kpatch-gcc " 2>&1 | logger || die +@@ -525,6 +526,7 @@ + + # Extract the target kernel version from vmlinux in this case. + ARCHVERSION="$(strings "$VMLINUX" | grep -m 1 -e "^Linux version" | awk '{ print($3); }')" ++ FLAVOR=${ARCHVERSION##*-} + fi + + [[ -z "$ARCHVERSION" ]] && ARCHVERSION="$(uname -r)" +@@ -717,18 +719,18 @@ + if [[ $DISTRO = ubuntu ]]; then + mv "$SRCDIR/debian" "$SRCDIR/debian.master" "$TEMPDIR" + make mrproper 2>&1 | logger || die +- rm -rf "$TEMPDIR/build-generic/spl" "$TEMPDIR/build-generic/zfs" ++ rm -rf "$TEMPDIR/build-$FLAVOR/spl" "$TEMPDIR/build-$FLAVOR/zfs" + mv "$TEMPDIR/debian" "$TEMPDIR/debian.master" "$SRCDIR" + fakeroot debian/rules clean 2>&1 | logger || die + MAKEFLAGS="--no-print-directory" debian/rules -j "$CPUS" \ +- build-generic build_image=vmlinux builddir="$TEMPDIR" \ ++ "build-$FLAVOR" build_image=vmlinux builddir="$TEMPDIR" \ + enable_zfs=false CROSS_COMPILE="$TOOLSDIR/kpatch-gcc\ " 2>&1 | logger \ + || die + ubuntu_build_external spl --with-linux="$SRCDIR" \ +- --with-linux-obj="$TEMPDIR/build-generic" | logger || die ++ --with-linux-obj="$TEMPDIR/build-$FLAVOR" | logger || die + ubuntu_build_external zfs --with-linux="$SRCDIR" \ +- --with-linux-obj="$TEMPDIR/build-generic" --with-spl="$SRCDIR/spl" \ +- --with-spl-obj="$TEMPDIR/build-generic/spl" --with-config=kernel | logger || die ++ --with-linux-obj="$TEMPDIR/build-$FLAVOR" --with-spl="$SRCDIR/spl" \ ++ --with-spl-obj="$TEMPDIR/build-$FLAVOR/spl" --with-config=kernel | logger || die + else + ./scripts/setlocalversion --save-scmversion || die + make mrproper 2>&1 | logger || die +@@ -747,9 +749,9 @@ + if [[ $DISTRO = ubuntu ]]; then + ubuntu_build_external spl || die + ubuntu_build_external zfs || die +- rm -f debian/stamps/stamp-build-generic ++ rm -f "debian/stamps/stamp-build-$FLAVOR" + MAKEFLAGS="--no-print-directory" debian/rules -j "$CPUS" \ +- build-generic build_image=vmlinux \ ++ "build-$FLAVOR" build_image=vmlinux \ + CROSS_COMPILE="$TOOLSDIR/kpatch-gcc\ " enable_zfs=false \ + LDFLAGS_vmlinux="--warn-unresolved-symbols" \ + KBUILD_MODPOST_WARN=1 builddir="$TEMPDIR" 2>&1 | logger || die +@@ -774,7 +776,7 @@ + do + mkdir -p "$TEMPDIR/patched/$(dirname "$i")" || die + if [[ $DISTRO = ubuntu ]]; then +- cp -f "$TEMPDIR/build-generic/$i" "$TEMPDIR/patched/$i" || die ++ cp -f "$TEMPDIR/build-$FLAVOR/$i" "$TEMPDIR/patched/$i" || die + else + cp -f "$SRCDIR/$i" "$TEMPDIR/patched/$i" || die + fi +@@ -820,7 +822,7 @@ + + mkdir -p "output/$(dirname "$i")" + if [[ "$DISTRO" = ubuntu ]]; then +- cd "$TEMPDIR/build-generic" || die ++ cd "$TEMPDIR/build-$FLAVOR" || die + else + cd "$SRCDIR" || die + fi +@@ -835,7 +837,7 @@ + if [[ "$DISTRO" = ubuntu ]]; then + # create-diff-object orig.o patched.o kernel-object output.o Module.symvers patch-mod-name + "$TOOLSDIR"/create-diff-object "orig/$i" "patched/$i" "$KOBJFILE" \ +- "output/$i" "$TEMPDIR/build-generic/Module.symvers" "${MODNAME//-/_}" 2>&1 | logger 1 ++ "output/$i" "$TEMPDIR/build-$FLAVOR/Module.symvers" "${MODNAME//-/_}" 2>&1 | logger 1 + check_pipe_status create-diff-object + else + # create-diff-object orig.o patched.o kernel-object output.o Module.symvers patch-mod-name +@@ -897,7 +899,7 @@ + cd "$TEMPDIR/patch" || die + + if [ "$DISTRO" = ubuntu ]; then +- KPATCH_BUILD="$TEMPDIR/build-generic" KPATCH_NAME="$MODNAME" \ ++ KPATCH_BUILD="$TEMPDIR/build-$FLAVOR" KPATCH_NAME="$MODNAME" \ + KBUILD_EXTRA_SYMBOLS="$KBUILD_EXTRA_SYMBOLS" \ + KPATCH_LDFLAGS="$KPATCH_LDFLAGS" \ + make 2>&1 | logger || die
  98. Download patch contrib/kpatch.service

    --- 0.3.2-3.1/contrib/kpatch.service 2016-02-17 21:37:18.000000000 +0000 +++ 0.5.0-0ubuntu2/contrib/kpatch.service 2017-12-21 05:02:48.000000000 +0000 @@ -1,5 +1,6 @@ [Unit] Description="Apply kpatch kernel patches" +ConditionKernelCommandLine=!kpatch.enable=0 [Service] Type=oneshot
  99. Download patch debian/patches/kmod-fix-symbol-lookup-on-linux-4.19.patch

    --- 0.3.2-3.1/debian/patches/kmod-fix-symbol-lookup-on-linux-4.19.patch 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/debian/patches/kmod-fix-symbol-lookup-on-linux-4.19.patch 2019-02-18 08:38:22.000000000 +0000 @@ -0,0 +1,41 @@ +From: Ben Hutchings <ben@decadent.org.uk> +Date: Mon, 07 Jan 2019 19:19:42 +0000 +Subject: kmod: Fix symbol lookup on Linux 4.19 + +Since Linux 4.19, symbols may contain either an absolute address or a +self-relative offset, depending on +CONFIG_HAVE_ARCH_PREL32_RELOCATIONS. The function to resolve the +address is unfortunately not inline or exported, so copy it here. + +Since the configuration symbol didn't exist before, we don't need to +add an explicit kernel version check. + +--- +--- a/kmod/core/core.c ++++ b/kmod/core/core.c +@@ -636,6 +636,16 @@ static int kpatch_find_object_symbol(con + return -EINVAL; + } + ++/* Copied from kernel/module.c */ ++static unsigned long kernel_symbol_value(const struct kernel_symbol *sym) ++{ ++#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS ++ return (unsigned long)offset_to_ptr(&sym->value_offset); ++#else ++ return sym->value; ++#endif ++} ++ + /* + * External symbols are located outside the parent object (where the parent + * object is either vmlinux or the kmod being patched). +@@ -651,7 +661,7 @@ static int kpatch_find_external_symbol(c + sym = find_symbol(name, NULL, NULL, true, true); + preempt_enable(); + if (sym) { +- *addr = sym->value; ++ *addr = kernel_symbol_value(sym); + return 0; + } +
  100. Download patch test/integration/centos-7/cmdline-string-LOADED.test

    --- 0.3.2-3.1/test/integration/centos-7/cmdline-string-LOADED.test 1970-01-01 00:00:00.000000000 +0000 +++ 0.5.0-0ubuntu2/test/integration/centos-7/cmdline-string-LOADED.test 2017-12-21 05:02:48.000000000 +0000 @@ -0,0 +1,3 @@ +#!/bin/bash + +grep kpatch=1 /proc/cmdline
  101. ...
  1. kpatch