From dc1d49a142cba01e439ba6656794528f1a651e5a Mon Sep 17 00:00:00 2001 From: Joe Lawrence Date: Fri, 29 Apr 2022 16:02:18 -0400 Subject: [PATCH 1/2] test/integration/rhel-9.0: add kernel-5.14.0-70.13.1.el9_0 tests * gcc-constprop.patch In v4.20, 33e26418193f ("y2038: make do_gettimeofday() and get_seconds() inline"), do_gettimeofdat() no longer exists as a stand alone function in kernel/time/timekeeping.c. * gcc-static-local-var-4.patch Unlike on rhel-8.4, _always_inline put_aio_ring_file() is causing too many inlines and results in modified, but not ftrace-able, __do_sys_io_submit() and __do_sys_io_setup(). Remove the annotation from this function. * module.patch In v4.20, 9ceddd9da134 ("knfsd: Allow lockless lookups of the exports"), the nfs_exports_op seq_operations converted to RCU protected lookups. Calling yield() from a kpatched e_show() results in a kernel warning, "Voluntary context switch within RCU read-side critical section!" Substitute with single_task_running(), which does not context switch or have any other side effects. In v5.10, ec6347bb4339 ("x86, powerpc: Rename memcpy_mcsafe() to copy_mc_to_{user, kernel}()") did away with the mcsafe_key. Use another exported static key like context_tracking_enabled. In v5.13, a0e2bf7cb700 ("x86/paravirt: Switch time pvops functions to use static_call()"), paravirt_sched_clock() was converted from a paravirt call to a non-exported static call. Update the x86 code to instead call __flush_tlb_local() (which is still a paravirt call). Signed-off-by: Joe Lawrence --- .../rhel-9.0/bug-table-section.patch | 12 ++ .../rhel-9.0/cmdline-string-LOADED.test | 3 + .../integration/rhel-9.0/cmdline-string.patch | 13 ++ .../integration/rhel-9.0/data-new-LOADED.test | 3 + test/integration/rhel-9.0/data-new.patch | 20 +++ .../rhel-9.0/data-read-mostly.patch | 11 ++ test/integration/rhel-9.0/fixup-section.patch | 11 ++ test/integration/rhel-9.0/gcc-isra.patch | 11 ++ test/integration/rhel-9.0/gcc-mangled-3.patch | 13 ++ .../rhel-9.0/gcc-static-local-var-2.patch | 13 ++ .../rhel-9.0/gcc-static-local-var-3.patch | 19 ++ .../rhel-9.0/gcc-static-local-var-4.patch | 22 +++ .../rhel-9.0/gcc-static-local-var-4.test | 8 + .../rhel-9.0/gcc-static-local-var-5.patch | 69 ++++++++ .../rhel-9.0/gcc-static-local-var-6.patch | 22 +++ .../rhel-9.0/macro-callbacks.patch | 155 ++++++++++++++++ test/integration/rhel-9.0/macro-printk.patch | 165 ++++++++++++++++++ .../rhel-9.0/meminfo-init-FAIL.patch | 11 ++ .../rhel-9.0/meminfo-init2-FAIL.patch | 19 ++ .../rhel-9.0/meminfo-string-LOADED.test | 3 + .../integration/rhel-9.0/meminfo-string.patch | 12 ++ test/integration/rhel-9.0/module-LOADED.test | 13 ++ test/integration/rhel-9.0/module.patch | 79 +++++++++ test/integration/rhel-9.0/multiple.test | 7 + test/integration/rhel-9.0/new-function.patch | 25 +++ test/integration/rhel-9.0/new-globals.patch | 34 ++++ .../rhel-9.0/parainstructions-section.patch | 11 ++ .../rhel-9.0/shadow-newpid-LOADED.test | 3 + test/integration/rhel-9.0/shadow-newpid.patch | 75 ++++++++ .../rhel-9.0/smp-locks-section.patch | 13 ++ .../integration/rhel-9.0/special-static.patch | 22 +++ .../rhel-9.0/symvers-disagreement-FAIL.patch | 46 +++++ test/integration/rhel-9.0/syscall.patch | 20 +++ .../rhel-9.0/tracepoints-section.patch | 18 ++ .../rhel-9.0/warn-detect-FAIL.patch | 9 + 35 files changed, 990 insertions(+) create mode 100644 test/integration/rhel-9.0/bug-table-section.patch create mode 100755 test/integration/rhel-9.0/cmdline-string-LOADED.test create mode 100644 test/integration/rhel-9.0/cmdline-string.patch create mode 100755 test/integration/rhel-9.0/data-new-LOADED.test create mode 100644 test/integration/rhel-9.0/data-new.patch create mode 100644 test/integration/rhel-9.0/data-read-mostly.patch create mode 100644 test/integration/rhel-9.0/fixup-section.patch create mode 100644 test/integration/rhel-9.0/gcc-isra.patch create mode 100644 test/integration/rhel-9.0/gcc-mangled-3.patch create mode 100644 test/integration/rhel-9.0/gcc-static-local-var-2.patch create mode 100644 test/integration/rhel-9.0/gcc-static-local-var-3.patch create mode 100644 test/integration/rhel-9.0/gcc-static-local-var-4.patch create mode 100755 test/integration/rhel-9.0/gcc-static-local-var-4.test create mode 100644 test/integration/rhel-9.0/gcc-static-local-var-5.patch create mode 100644 test/integration/rhel-9.0/gcc-static-local-var-6.patch create mode 100644 test/integration/rhel-9.0/macro-callbacks.patch create mode 100644 test/integration/rhel-9.0/macro-printk.patch create mode 100644 test/integration/rhel-9.0/meminfo-init-FAIL.patch create mode 100644 test/integration/rhel-9.0/meminfo-init2-FAIL.patch create mode 100755 test/integration/rhel-9.0/meminfo-string-LOADED.test create mode 100644 test/integration/rhel-9.0/meminfo-string.patch create mode 100755 test/integration/rhel-9.0/module-LOADED.test create mode 100644 test/integration/rhel-9.0/module.patch create mode 100755 test/integration/rhel-9.0/multiple.test create mode 100644 test/integration/rhel-9.0/new-function.patch create mode 100644 test/integration/rhel-9.0/new-globals.patch create mode 100644 test/integration/rhel-9.0/parainstructions-section.patch create mode 100755 test/integration/rhel-9.0/shadow-newpid-LOADED.test create mode 100644 test/integration/rhel-9.0/shadow-newpid.patch create mode 100644 test/integration/rhel-9.0/smp-locks-section.patch create mode 100644 test/integration/rhel-9.0/special-static.patch create mode 100644 test/integration/rhel-9.0/symvers-disagreement-FAIL.patch create mode 100644 test/integration/rhel-9.0/syscall.patch create mode 100644 test/integration/rhel-9.0/tracepoints-section.patch create mode 100644 test/integration/rhel-9.0/warn-detect-FAIL.patch diff --git a/test/integration/rhel-9.0/bug-table-section.patch b/test/integration/rhel-9.0/bug-table-section.patch new file mode 100644 index 0000000..714bfb0 --- /dev/null +++ b/test/integration/rhel-9.0/bug-table-section.patch @@ -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 2022-04-29 15:52:13.400335767 -0400 ++++ src/fs/proc/proc_sysctl.c 2022-04-29 15:52:14.157338461 -0400 +@@ -302,6 +302,8 @@ static void start_unregistering(struct c + + 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)) diff --git a/test/integration/rhel-9.0/cmdline-string-LOADED.test b/test/integration/rhel-9.0/cmdline-string-LOADED.test new file mode 100755 index 0000000..a8e0a08 --- /dev/null +++ b/test/integration/rhel-9.0/cmdline-string-LOADED.test @@ -0,0 +1,3 @@ +#!/bin/bash + +grep kpatch=1 /proc/cmdline diff --git a/test/integration/rhel-9.0/cmdline-string.patch b/test/integration/rhel-9.0/cmdline-string.patch new file mode 100644 index 0000000..871d61f --- /dev/null +++ b/test/integration/rhel-9.0/cmdline-string.patch @@ -0,0 +1,13 @@ +diff -Nupr src.orig/fs/proc/cmdline.c src/fs/proc/cmdline.c +--- src.orig/fs/proc/cmdline.c 2022-04-29 15:52:13.399335763 -0400 ++++ src/fs/proc/cmdline.c 2022-04-29 15:52:17.041348724 -0400 +@@ -6,8 +6,7 @@ + + static int cmdline_proc_show(struct seq_file *m, void *v) + { +- seq_puts(m, saved_command_line); +- seq_putc(m, '\n'); ++ seq_printf(m, "%s kpatch=1\n", saved_command_line); + return 0; + } + diff --git a/test/integration/rhel-9.0/data-new-LOADED.test b/test/integration/rhel-9.0/data-new-LOADED.test new file mode 100755 index 0000000..9f25744 --- /dev/null +++ b/test/integration/rhel-9.0/data-new-LOADED.test @@ -0,0 +1,3 @@ +#!/bin/bash + +grep "kpatch: 5" /proc/meminfo diff --git a/test/integration/rhel-9.0/data-new.patch b/test/integration/rhel-9.0/data-new.patch new file mode 100644 index 0000000..6b94642 --- /dev/null +++ b/test/integration/rhel-9.0/data-new.patch @@ -0,0 +1,20 @@ +diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c +--- src.orig/fs/proc/meminfo.c 2022-04-29 15:52:13.399335763 -0400 ++++ src/fs/proc/meminfo.c 2022-04-29 15:52:20.014359304 -0400 +@@ -29,6 +29,8 @@ static void show_val_kb(struct seq_file + seq_write(m, " kB\n", 4); + } + ++static int foo = 5; ++ + static int meminfo_proc_show(struct seq_file *m, void *v) + { + struct sysinfo i; +@@ -145,6 +147,7 @@ static int meminfo_proc_show(struct seq_ + show_val_kb(m, "CmaFree: ", + global_zone_page_state(NR_FREE_CMA_PAGES)); + #endif ++ seq_printf(m, "kpatch: %d\n", foo); + + hugetlb_report_meminfo(m); + diff --git a/test/integration/rhel-9.0/data-read-mostly.patch b/test/integration/rhel-9.0/data-read-mostly.patch new file mode 100644 index 0000000..194d728 --- /dev/null +++ b/test/integration/rhel-9.0/data-read-mostly.patch @@ -0,0 +1,11 @@ +diff -Nupr src.orig/net/core/dev.c src/net/core/dev.c +--- src.orig/net/core/dev.c 2022-04-29 15:52:13.627336575 -0400 ++++ src/net/core/dev.c 2022-04-29 15:52:22.819369286 -0400 +@@ -5405,6 +5405,7 @@ skip_classify: + case RX_HANDLER_PASS: + break; + default: ++ printk("BUG!\n"); + BUG(); + } + } diff --git a/test/integration/rhel-9.0/fixup-section.patch b/test/integration/rhel-9.0/fixup-section.patch new file mode 100644 index 0000000..a163177 --- /dev/null +++ b/test/integration/rhel-9.0/fixup-section.patch @@ -0,0 +1,11 @@ +diff -Nupr src.orig/fs/readdir.c src/fs/readdir.c +--- src.orig/fs/readdir.c 2022-04-29 15:52:13.347335578 -0400 ++++ src/fs/readdir.c 2022-04-29 15:52:25.604379197 -0400 +@@ -245,6 +245,7 @@ static int filldir(struct dir_context *c + if (prev_reclen && signal_pending(current)) + return -EINTR; + dirent = buf->current_dir; ++ asm("nop"); + prev = (void __user *) dirent - prev_reclen; + if (!user_write_access_begin(prev, reclen + prev_reclen)) + goto efault; diff --git a/test/integration/rhel-9.0/gcc-isra.patch b/test/integration/rhel-9.0/gcc-isra.patch new file mode 100644 index 0000000..8a6c17b --- /dev/null +++ b/test/integration/rhel-9.0/gcc-isra.patch @@ -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 2022-04-29 15:52:13.400335767 -0400 ++++ src/fs/proc/proc_sysctl.c 2022-04-29 15:52:28.391389115 -0400 +@@ -55,6 +55,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); + } diff --git a/test/integration/rhel-9.0/gcc-mangled-3.patch b/test/integration/rhel-9.0/gcc-mangled-3.patch new file mode 100644 index 0000000..7be534b --- /dev/null +++ b/test/integration/rhel-9.0/gcc-mangled-3.patch @@ -0,0 +1,13 @@ +diff -Nupr src.orig/mm/slub.c src/mm/slub.c +--- src.orig/mm/slub.c 2022-04-29 15:52:13.612336521 -0400 ++++ src/mm/slub.c 2022-04-29 15:52:31.210399147 -0400 +@@ -6222,6 +6222,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); diff --git a/test/integration/rhel-9.0/gcc-static-local-var-2.patch b/test/integration/rhel-9.0/gcc-static-local-var-2.patch new file mode 100644 index 0000000..34bdbec --- /dev/null +++ b/test/integration/rhel-9.0/gcc-static-local-var-2.patch @@ -0,0 +1,13 @@ +diff -Nupr src.orig/mm/mmap.c src/mm/mmap.c +--- src.orig/mm/mmap.c 2022-04-29 15:52:13.610336514 -0400 ++++ src/mm/mmap.c 2022-04-29 15:52:34.000409076 -0400 +@@ -1723,6 +1723,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, vm_flags, len >> PAGE_SHIFT)) { + unsigned long nr_pages; diff --git a/test/integration/rhel-9.0/gcc-static-local-var-3.patch b/test/integration/rhel-9.0/gcc-static-local-var-3.patch new file mode 100644 index 0000000..0b201ff --- /dev/null +++ b/test/integration/rhel-9.0/gcc-static-local-var-3.patch @@ -0,0 +1,19 @@ +diff -Nupr src.orig/kernel/reboot.c src/kernel/reboot.c +--- src.orig/kernel/reboot.c 2022-04-29 15:52:13.578336400 -0400 ++++ src/kernel/reboot.c 2022-04-29 15:52:36.769418930 -0400 +@@ -397,8 +397,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); + } + diff --git a/test/integration/rhel-9.0/gcc-static-local-var-4.patch b/test/integration/rhel-9.0/gcc-static-local-var-4.patch new file mode 100644 index 0000000..5c2173c --- /dev/null +++ b/test/integration/rhel-9.0/gcc-static-local-var-4.patch @@ -0,0 +1,22 @@ +diff -Nupr src.orig/fs/aio.c src/fs/aio.c +--- src.orig/fs/aio.c 2022-04-29 15:52:13.345335571 -0400 ++++ src/fs/aio.c 2022-04-29 15:52:39.560428863 -0400 +@@ -278,11 +278,18 @@ 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; + struct address_space *i_mapping; + ++ kpatch_aio_foo(); + if (aio_ring_file) { + truncate_setsize(file_inode(aio_ring_file), 0); + diff --git a/test/integration/rhel-9.0/gcc-static-local-var-4.test b/test/integration/rhel-9.0/gcc-static-local-var-4.test new file mode 100755 index 0000000..e085f93 --- /dev/null +++ b/test/integration/rhel-9.0/gcc-static-local-var-4.test @@ -0,0 +1,8 @@ +#!/bin/bash + +set -o pipefail +if ! $(eu-readelf --wide --symbols test-gcc-static-local-var-4.ko | awk '$NF == "free_ioctx" { exit 1 }'); then + exit 1 +else + exit 0 +fi diff --git a/test/integration/rhel-9.0/gcc-static-local-var-5.patch b/test/integration/rhel-9.0/gcc-static-local-var-5.patch new file mode 100644 index 0000000..07d9183 --- /dev/null +++ b/test/integration/rhel-9.0/gcc-static-local-var-5.patch @@ -0,0 +1,69 @@ +diff -Nupr src.orig/kernel/audit.c src/kernel/audit.c +--- src.orig/kernel/audit.c 2022-04-29 15:52:13.576336393 -0400 ++++ src/kernel/audit.c 2022-04-29 15:52:42.384438912 -0400 +@@ -314,6 +314,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; +@@ -324,6 +330,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); +@@ -343,6 +350,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 +@@ -389,6 +401,8 @@ static int audit_log_config_change(char + struct audit_buffer *ab; + int rc = 0; + ++ kpatch_audit_check(); ++ + ab = audit_log_start(audit_context(), GFP_KERNEL, AUDIT_CONFIG_CHANGE); + if (unlikely(!ab)) + return rc; +@@ -1095,6 +1109,7 @@ static int audit_get_feature(struct sk_b + return 0; + } + ++__attribute__((optimize("-fno-optimize-sibling-calls"))) + static void audit_log_feature_change(int which, u32 old_feature, u32 new_feature, + u32 old_lock, u32 new_lock, int res) + { +@@ -2230,6 +2245,7 @@ EXPORT_SYMBOL(audit_log_task_info); + * @type: audit message type (AUDIT_ANOM_LINK, AUDIT_ANOM_CREAT, etc) + * @operation: specific operation name + */ ++__attribute__((optimize("-fno-optimize-sibling-calls"))) + void audit_log_path_denied(int type, const char *operation) + { + struct audit_buffer *ab; +@@ -2368,6 +2384,7 @@ int audit_signal_info(int sig, struct ta + * queue and a kthread is scheduled to remove them from the queue outside the + * irq context. May be called in any context. + */ ++__attribute__((optimize("-fno-optimize-sibling-calls"))) + void audit_log_end(struct audit_buffer *ab) + { + struct sk_buff *skb; diff --git a/test/integration/rhel-9.0/gcc-static-local-var-6.patch b/test/integration/rhel-9.0/gcc-static-local-var-6.patch new file mode 100644 index 0000000..dbd9f34 --- /dev/null +++ b/test/integration/rhel-9.0/gcc-static-local-var-6.patch @@ -0,0 +1,22 @@ +diff -Nupr src.orig/net/ipv6/netfilter.c src/net/ipv6/netfilter.c +--- src.orig/net/ipv6/netfilter.c 2022-04-29 15:52:13.640336621 -0400 ++++ src/net/ipv6/netfilter.c 2022-04-29 15:52:45.295449272 -0400 +@@ -91,6 +91,8 @@ static int nf_ip6_reroute(struct sk_buff + return 0; + } + ++#include "kpatch-macros.h" ++ + int __nf_ip6_route(struct net *net, struct dst_entry **dst, + struct flowi *fl, bool strict) + { +@@ -104,6 +106,9 @@ int __nf_ip6_route(struct net *net, stru + struct dst_entry *result; + int err; + ++ if (!jiffies) ++ printk("kpatch nf_ip6_route foo\n"); ++ + result = ip6_route_output(net, sk, &fl->u.ip6); + err = result->error; + if (err) diff --git a/test/integration/rhel-9.0/macro-callbacks.patch b/test/integration/rhel-9.0/macro-callbacks.patch new file mode 100644 index 0000000..ab018c3 --- /dev/null +++ b/test/integration/rhel-9.0/macro-callbacks.patch @@ -0,0 +1,155 @@ +diff -Nupr src.orig/drivers/input/joydev.c src/drivers/input/joydev.c +--- src.orig/drivers/input/joydev.c 2022-04-29 15:52:12.634333041 -0400 ++++ src/drivers/input/joydev.c 2022-04-29 15:52:48.073459158 -0400 +@@ -1086,3 +1086,47 @@ static void __exit joydev_exit(void) + + module_init(joydev_init); + module_exit(joydev_exit); ++ ++#include ++#include "kpatch-macros.h" ++ ++static const char *const module_state[] = { ++ [MODULE_STATE_LIVE] = "[MODULE_STATE_LIVE] Normal state", ++ [MODULE_STATE_COMING] = "[MODULE_STATE_COMING] Full formed, running module_init", ++ [MODULE_STATE_GOING] = "[MODULE_STATE_GOING] Going away", ++ [MODULE_STATE_UNFORMED] = "[MODULE_STATE_UNFORMED] Still setting it up", ++}; ++ ++static void callback_info(const char *callback, patch_object *obj) ++{ ++ if (obj->mod) ++ pr_info("%s: %s -> %s\n", callback, obj->mod->name, ++ module_state[obj->mod->state]); ++ else ++ pr_info("%s: vmlinux\n", callback); ++} ++ ++static int pre_patch_callback(patch_object *obj) ++{ ++ callback_info(__func__, obj); ++ return 0; /* return -ENODEV; */ ++} ++KPATCH_PRE_PATCH_CALLBACK(pre_patch_callback); ++ ++static void post_patch_callback(patch_object *obj) ++{ ++ callback_info(__func__, obj); ++} ++KPATCH_POST_PATCH_CALLBACK(post_patch_callback); ++ ++static void pre_unpatch_callback(patch_object *obj) ++{ ++ callback_info(__func__, obj); ++} ++KPATCH_PRE_UNPATCH_CALLBACK(pre_unpatch_callback); ++ ++static void post_unpatch_callback(patch_object *obj) ++{ ++ callback_info(__func__, obj); ++} ++KPATCH_POST_UNPATCH_CALLBACK(post_unpatch_callback); +diff -Nupr src.orig/drivers/input/misc/pcspkr.c src/drivers/input/misc/pcspkr.c +--- src.orig/drivers/input/misc/pcspkr.c 2022-04-29 15:52:12.640333062 -0400 ++++ src/drivers/input/misc/pcspkr.c 2022-04-29 15:52:48.073459158 -0400 +@@ -134,3 +134,46 @@ static struct platform_driver pcspkr_pla + }; + module_platform_driver(pcspkr_platform_driver); + ++#include ++#include "kpatch-macros.h" ++ ++static const char *const module_state[] = { ++ [MODULE_STATE_LIVE] = "[MODULE_STATE_LIVE] Normal state", ++ [MODULE_STATE_COMING] = "[MODULE_STATE_COMING] Full formed, running module_init", ++ [MODULE_STATE_GOING] = "[MODULE_STATE_GOING] Going away", ++ [MODULE_STATE_UNFORMED] = "[MODULE_STATE_UNFORMED] Still setting it up", ++}; ++ ++static void callback_info(const char *callback, patch_object *obj) ++{ ++ if (obj->mod) ++ pr_info("%s: %s -> %s\n", callback, obj->mod->name, ++ module_state[obj->mod->state]); ++ else ++ pr_info("%s: vmlinux\n", callback); ++} ++ ++static int pre_patch_callback(patch_object *obj) ++{ ++ callback_info(__func__, obj); ++ return 0; ++} ++KPATCH_PRE_PATCH_CALLBACK(pre_patch_callback); ++ ++static void post_patch_callback(patch_object *obj) ++{ ++ callback_info(__func__, obj); ++} ++KPATCH_POST_PATCH_CALLBACK(post_patch_callback); ++ ++static void pre_unpatch_callback(patch_object *obj) ++{ ++ callback_info(__func__, obj); ++} ++KPATCH_PRE_UNPATCH_CALLBACK(pre_unpatch_callback); ++ ++static void post_unpatch_callback(patch_object *obj) ++{ ++ callback_info(__func__, obj); ++} ++KPATCH_POST_UNPATCH_CALLBACK(post_unpatch_callback); +diff -Nupr src.orig/fs/aio.c src/fs/aio.c +--- src.orig/fs/aio.c 2022-04-29 15:52:13.345335571 -0400 ++++ src/fs/aio.c 2022-04-29 15:52:48.073459158 -0400 +@@ -50,6 +50,50 @@ + + #define KIOCB_KEY 0 + ++#include ++#include "kpatch-macros.h" ++ ++static const char *const module_state[] = { ++ [MODULE_STATE_LIVE] = "[MODULE_STATE_LIVE] Normal state", ++ [MODULE_STATE_COMING] = "[MODULE_STATE_COMING] Full formed, running module_init", ++ [MODULE_STATE_GOING] = "[MODULE_STATE_GOING] Going away", ++ [MODULE_STATE_UNFORMED] = "[MODULE_STATE_UNFORMED] Still setting it up", ++}; ++ ++static void callback_info(const char *callback, patch_object *obj) ++{ ++ if (obj->mod) ++ pr_info("%s: %s -> %s\n", callback, obj->mod->name, ++ module_state[obj->mod->state]); ++ else ++ pr_info("%s: vmlinux\n", callback); ++} ++ ++static int pre_patch_callback(patch_object *obj) ++{ ++ callback_info(__func__, obj); ++ return 0; ++} ++KPATCH_PRE_PATCH_CALLBACK(pre_patch_callback); ++ ++static void post_patch_callback(patch_object *obj) ++{ ++ callback_info(__func__, obj); ++} ++KPATCH_POST_PATCH_CALLBACK(post_patch_callback); ++ ++static void pre_unpatch_callback(patch_object *obj) ++{ ++ callback_info(__func__, obj); ++} ++KPATCH_PRE_UNPATCH_CALLBACK(pre_unpatch_callback); ++ ++static void post_unpatch_callback(patch_object *obj) ++{ ++ callback_info(__func__, obj); ++} ++KPATCH_POST_UNPATCH_CALLBACK(post_unpatch_callback); ++ + #define AIO_RING_MAGIC 0xa10a10a1 + #define AIO_RING_COMPAT_FEATURES 1 + #define AIO_RING_INCOMPAT_FEATURES 0 diff --git a/test/integration/rhel-9.0/macro-printk.patch b/test/integration/rhel-9.0/macro-printk.patch new file mode 100644 index 0000000..77c3ddf --- /dev/null +++ b/test/integration/rhel-9.0/macro-printk.patch @@ -0,0 +1,165 @@ +diff -Nupr src.orig/net/ipv4/fib_frontend.c src/net/ipv4/fib_frontend.c +--- src.orig/net/ipv4/fib_frontend.c 2022-04-29 15:52:13.635336603 -0400 ++++ src/net/ipv4/fib_frontend.c 2022-04-29 15:52:50.873469122 -0400 +@@ -865,6 +865,7 @@ errout: + return err; + } + ++#include "kpatch-macros.h" + static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, + struct netlink_ext_ack *extack) + { +@@ -886,6 +887,7 @@ static int inet_rtm_newroute(struct sk_b + err = fib_table_insert(net, tb, &cfg, extack); + if (!err && cfg.fc_type == RTN_LOCAL) + net->ipv4.fib_has_custom_local_routes = true; ++ 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 2022-04-29 15:52:13.635336603 -0400 ++++ src/net/ipv4/fib_semantics.c 2022-04-29 15:52:50.873469122 -0400 +@@ -1342,6 +1342,7 @@ static bool fib_valid_prefsrc(struct fib + return true; + } + ++#include "kpatch-macros.h" + struct fib_info *fib_create_info(struct fib_config *cfg, + struct netlink_ext_ack *extack) + { +@@ -1393,6 +1394,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; +@@ -1413,6 +1415,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(struct_size(fi, fib_nh, nhs), GFP_KERNEL); + if (!fi) +@@ -1426,6 +1429,8 @@ struct fib_info *fib_create_info(struct + } + + 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; + fi->fib_scope = cfg->fc_scope; +@@ -1452,13 +1457,18 @@ struct fib_info *fib_create_info(struct + if (cfg->fc_mp) + err = fib_get_nhs(fi, cfg->fc_mp, cfg->fc_mp_len, cfg, + extack); +- else ++ else { ++ KPATCH_PRINTK("[fib_create_info]: 4 create error err is %d\n",err); + err = fib_nh_init(net, fi->fib_nh, cfg, 1, extack); ++ KPATCH_PRINTK("[fib_create_info]: 5 create error err is %d\n",err); ++ } + } + + if (err != 0) + goto failure; + ++ KPATCH_PRINTK("[fib_create_info]: 6 create error err is %d\n",err); ++ + if (fib_props[cfg->fc_type].error) { + if (cfg->fc_gw_family || cfg->fc_oif || cfg->fc_mp) { + NL_SET_ERR_MSG(extack, +@@ -1479,6 +1489,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) { + NL_SET_ERR_MSG(extack, "Invalid scope"); +@@ -1523,6 +1534,7 @@ struct fib_info *fib_create_info(struct + if (linkdown == fi->fib_nhs) + fi->fib_flags |= RTNH_F_LINKDOWN; + } ++ KPATCH_PRINTK("[fib_create_info]: 8 create error err is %d\n",err); + + if (fi->fib_prefsrc && !fib_valid_prefsrc(cfg, fi->fib_prefsrc)) { + NL_SET_ERR_MSG(extack, "Invalid prefsrc address"); +@@ -1536,6 +1548,7 @@ struct fib_info *fib_create_info(struct + if (nexthop_nh->fib_nh_gw_family == AF_INET6) + fi->fib_nh_is_v6 = true; + } endfor_nexthops(fi) ++ KPATCH_PRINTK("[fib_create_info]: 9 create error err is %d\n",err); + + fib_rebalance(fi); + } +@@ -1548,6 +1561,7 @@ link_it: + ofi->fib_treeref++; + return ofi; + } ++ KPATCH_PRINTK("[fib_create_info]: 10 create error err is %d\n",err); + + fi->fib_treeref++; + refcount_set(&fi->fib_clntref, 1); +@@ -1575,6 +1589,7 @@ link_it: + } 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: +@@ -1585,6 +1600,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 2022-04-29 15:52:13.635336603 -0400 ++++ src/net/ipv4/fib_trie.c 2022-04-29 15:52:50.874469126 -0400 +@@ -532,6 +532,7 @@ static struct key_vector *replace(struct + return tp; + } + ++__attribute__((optimize("-fno-optimize-sibling-calls"))) + static struct key_vector *inflate(struct trie *t, + struct key_vector *oldtnode) + { +@@ -628,6 +629,7 @@ notnode: + return NULL; + } + ++__attribute__((optimize("-fno-optimize-sibling-calls"))) + static struct key_vector *halve(struct trie *t, + struct key_vector *oldtnode) + { +@@ -1200,6 +1202,7 @@ static void fib_remove_alias(struct trie + struct key_vector *l, struct fib_alias *old); + + /* Caller must hold RTNL. */ ++#include "kpatch-macros.h" + int fib_table_insert(struct net *net, struct fib_table *tb, + struct fib_config *cfg, struct netlink_ext_ack *extack) + { +@@ -1221,11 +1224,14 @@ int fib_table_insert(struct net *net, st + + pr_debug("Insert table=%u %08x/%d\n", tb->tb_id, key, plen); + ++ KPATCH_PRINTK("[fib_table_insert]: start\n"); + fi = fib_create_info(cfg, extack); + 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, diff --git a/test/integration/rhel-9.0/meminfo-init-FAIL.patch b/test/integration/rhel-9.0/meminfo-init-FAIL.patch new file mode 100644 index 0000000..95e5472 --- /dev/null +++ b/test/integration/rhel-9.0/meminfo-init-FAIL.patch @@ -0,0 +1,11 @@ +diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c +--- src.orig/fs/proc/meminfo.c 2022-04-29 15:52:13.399335763 -0400 ++++ src/fs/proc/meminfo.c 2022-04-29 15:52:56.486489097 -0400 +@@ -155,6 +155,7 @@ static int meminfo_proc_show(struct seq_ + + static int __init proc_meminfo_init(void) + { ++ printk("a\n"); + proc_create_single("meminfo", 0, NULL, meminfo_proc_show); + return 0; + } diff --git a/test/integration/rhel-9.0/meminfo-init2-FAIL.patch b/test/integration/rhel-9.0/meminfo-init2-FAIL.patch new file mode 100644 index 0000000..7f64d0f --- /dev/null +++ b/test/integration/rhel-9.0/meminfo-init2-FAIL.patch @@ -0,0 +1,19 @@ +diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c +--- src.orig/fs/proc/meminfo.c 2022-04-29 15:52:13.399335763 -0400 ++++ src/fs/proc/meminfo.c 2022-04-29 15:52:53.660479040 -0400 +@@ -39,6 +39,7 @@ static int meminfo_proc_show(struct seq_ + unsigned long sreclaimable, sunreclaim; + int lru; + ++ printk("a\n"); + si_meminfo(&i); + si_swapinfo(&i); + committed = vm_memory_committed(); +@@ -155,6 +156,7 @@ static int meminfo_proc_show(struct seq_ + + static int __init proc_meminfo_init(void) + { ++ printk("a\n"); + proc_create_single("meminfo", 0, NULL, meminfo_proc_show); + return 0; + } diff --git a/test/integration/rhel-9.0/meminfo-string-LOADED.test b/test/integration/rhel-9.0/meminfo-string-LOADED.test new file mode 100755 index 0000000..10dc20b --- /dev/null +++ b/test/integration/rhel-9.0/meminfo-string-LOADED.test @@ -0,0 +1,3 @@ +#!/bin/bash + +grep VMALLOCCHUNK /proc/meminfo diff --git a/test/integration/rhel-9.0/meminfo-string.patch b/test/integration/rhel-9.0/meminfo-string.patch new file mode 100644 index 0000000..77d41e5 --- /dev/null +++ b/test/integration/rhel-9.0/meminfo-string.patch @@ -0,0 +1,12 @@ +diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c +--- src.orig/fs/proc/meminfo.c 2022-04-29 15:52:13.399335763 -0400 ++++ src/fs/proc/meminfo.c 2022-04-29 15:52:59.251498937 -0400 +@@ -119,7 +119,7 @@ static int meminfo_proc_show(struct seq_ + seq_printf(m, "VmallocTotal: %8lu kB\n", + (unsigned long)VMALLOC_TOTAL >> 10); + show_val_kb(m, "VmallocUsed: ", vmalloc_nr_pages()); +- show_val_kb(m, "VmallocChunk: ", 0ul); ++ show_val_kb(m, "VMALLOCCHUNK: ", 0ul); + show_val_kb(m, "Percpu: ", pcpu_nr_pages()); + + #ifdef CONFIG_MEMORY_FAILURE diff --git a/test/integration/rhel-9.0/module-LOADED.test b/test/integration/rhel-9.0/module-LOADED.test new file mode 100755 index 0000000..72bb852 --- /dev/null +++ b/test/integration/rhel-9.0/module-LOADED.test @@ -0,0 +1,13 @@ +#!/bin/bash + +set -o errexit + +sudo modprobe nfsd +sleep 5 +grep -q kpatch /proc/fs/nfs/exports + +# TODO: This will trigger a printk on newer kernels which have the .klp.arch +# removal. Don't actually do the grep until running on a newer kernel. +echo "file fs/nfsd/export.c +p" > /sys/kernel/debug/dynamic_debug/control +cat /proc/fs/nfs/exports > /dev/null +# dmesg | grep -q "kpatch: pr_debug" diff --git a/test/integration/rhel-9.0/module.patch b/test/integration/rhel-9.0/module.patch new file mode 100644 index 0000000..f83d265 --- /dev/null +++ b/test/integration/rhel-9.0/module.patch @@ -0,0 +1,79 @@ +kpatch module integration test + +This tests several things related to the patching of modules: + +- 'kpatch_string' tests the referencing of a symbol which is outside the + .o, but inside the patch module. + +- alternatives patching (.altinstructions) + +- paravirt patching (.parainstructions) + +- jump labels (5.8+ kernels only) -- including dynamic printk + +Signed-off-by: Josh Poimboeuf + +diff -Nupr src.orig/fs/nfsd/export.c src/fs/nfsd/export.c +--- src.orig/fs/nfsd/export.c 2022-04-29 15:52:13.385335713 -0400 ++++ src/fs/nfsd/export.c 2022-04-29 15:53:02.037508852 -0400 +@@ -1294,6 +1294,10 @@ static void exp_flags(struct seq_file *m + } + } + ++#include ++extern char *kpatch_string(void); ++ ++__attribute__((optimize("-fno-optimize-sibling-calls"))) + static int e_show(struct seq_file *m, void *p) + { + struct cache_head *cp = p; +@@ -1301,12 +1305,36 @@ static int e_show(struct seq_file *m, vo + struct cache_detail *cd = m->private; + bool export_stats = is_export_stats_file(m); + ++#ifdef CONFIG_X86_64 ++ alternative("ud2", "call single_task_running", X86_FEATURE_ALWAYS); ++ alternative("call single_task_running", "ud2", X86_FEATURE_IA64); ++ ++ __flush_tlb_local(); /* paravirt call */ ++#endif ++ ++ pr_debug("kpatch: pr_debug() test\n"); ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) ++{ ++ static DEFINE_STATIC_KEY_TRUE(kpatch_key); ++ ++ if (static_branch_unlikely(&memcg_kmem_enabled_key)) ++ printk("kpatch: memcg_kmem_enabled_key\n"); ++ ++ BUG_ON(!static_branch_likely(&kpatch_key)); ++ static_branch_disable(&kpatch_key); ++ BUG_ON(static_branch_likely(&kpatch_key)); ++ static_branch_enable(&kpatch_key); ++} ++#endif ++ + if (p == SEQ_START_TOKEN) { + seq_puts(m, "# Version 1.1\n"); + if (export_stats) + seq_puts(m, "# Path Client Start-time\n#\tStats\n"); + else + 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 2022-04-29 15:52:13.657336681 -0400 ++++ src/net/netlink/af_netlink.c 2022-04-29 15:53:02.038508855 -0400 +@@ -2908,4 +2908,9 @@ panic: + panic("netlink_init: Cannot allocate nl_table\n"); + } + ++char *kpatch_string(void) ++{ ++ return "# kpatch\n"; ++} ++ + core_initcall(netlink_proto_init); diff --git a/test/integration/rhel-9.0/multiple.test b/test/integration/rhel-9.0/multiple.test new file mode 100755 index 0000000..7e4b352 --- /dev/null +++ b/test/integration/rhel-9.0/multiple.test @@ -0,0 +1,7 @@ +#!/bin/bash + +SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))" + +declare -a blacklist=(meminfo-string-LOADED.test) + +source ${SCRIPTDIR}/../common/multiple.template diff --git a/test/integration/rhel-9.0/new-function.patch b/test/integration/rhel-9.0/new-function.patch new file mode 100644 index 0000000..3e6cadd --- /dev/null +++ b/test/integration/rhel-9.0/new-function.patch @@ -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 2022-04-29 15:52:13.274335318 -0400 ++++ src/drivers/tty/n_tty.c 2022-04-29 15:53:04.777518603 -0400 +@@ -2253,7 +2253,7 @@ more_to_be_read: + * 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; +@@ -2340,6 +2340,12 @@ break_out: + return (b - buf) ? b - buf : retval; + } + ++static ssize_t __attribute__((optimize("-fno-optimize-sibling-calls"))) 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 diff --git a/test/integration/rhel-9.0/new-globals.patch b/test/integration/rhel-9.0/new-globals.patch new file mode 100644 index 0000000..a296821 --- /dev/null +++ b/test/integration/rhel-9.0/new-globals.patch @@ -0,0 +1,34 @@ +diff -Nupr src.orig/fs/proc/cmdline.c src/fs/proc/cmdline.c +--- src.orig/fs/proc/cmdline.c 2022-04-29 15:52:13.399335763 -0400 ++++ src/fs/proc/cmdline.c 2022-04-29 15:53:07.589528610 -0400 +@@ -17,3 +17,10 @@ static int __init proc_cmdline_init(void + return 0; + } + fs_initcall(proc_cmdline_init); ++ ++#include ++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 2022-04-29 15:52:13.399335763 -0400 ++++ src/fs/proc/meminfo.c 2022-04-29 15:53:07.589528610 -0400 +@@ -19,6 +19,8 @@ + #include + #include "internal.h" + ++void kpatch_print_message(void); ++ + void __attribute__((weak)) arch_report_meminfo(struct seq_file *m) + { + } +@@ -55,6 +57,7 @@ static int meminfo_proc_show(struct seq_ + sreclaimable = global_node_page_state_pages(NR_SLAB_RECLAIMABLE_B); + sunreclaim = global_node_page_state_pages(NR_SLAB_UNRECLAIMABLE_B); + ++ kpatch_print_message(); + show_val_kb(m, "MemTotal: ", i.totalram); + show_val_kb(m, "MemFree: ", i.freeram); + show_val_kb(m, "MemAvailable: ", available); diff --git a/test/integration/rhel-9.0/parainstructions-section.patch b/test/integration/rhel-9.0/parainstructions-section.patch new file mode 100644 index 0000000..4d7c8e5 --- /dev/null +++ b/test/integration/rhel-9.0/parainstructions-section.patch @@ -0,0 +1,11 @@ +diff -Nupr src.orig/fs/proc/generic.c src/fs/proc/generic.c +--- src.orig/fs/proc/generic.c 2022-04-29 15:52:13.399335763 -0400 ++++ src/fs/proc/generic.c 2022-04-29 15:53:10.475538880 -0400 +@@ -203,6 +203,7 @@ int proc_alloc_inum(unsigned int *inum) + { + int i; + ++ printk("kpatch-test: testing change to .parainstructions section\n"); + i = ida_simple_get(&proc_inum_ida, 0, UINT_MAX - PROC_DYNAMIC_FIRST + 1, + GFP_KERNEL); + if (i < 0) diff --git a/test/integration/rhel-9.0/shadow-newpid-LOADED.test b/test/integration/rhel-9.0/shadow-newpid-LOADED.test new file mode 100755 index 0000000..c07d112 --- /dev/null +++ b/test/integration/rhel-9.0/shadow-newpid-LOADED.test @@ -0,0 +1,3 @@ +#!/bin/bash + +grep -q newpid: /proc/$$/status diff --git a/test/integration/rhel-9.0/shadow-newpid.patch b/test/integration/rhel-9.0/shadow-newpid.patch new file mode 100644 index 0000000..c020e28 --- /dev/null +++ b/test/integration/rhel-9.0/shadow-newpid.patch @@ -0,0 +1,75 @@ +diff -Nupr src.orig/fs/proc/array.c src/fs/proc/array.c +--- src.orig/fs/proc/array.c 2022-04-29 15:52:13.399335763 -0400 ++++ src/fs/proc/array.c 2022-04-29 15:53:13.252548763 -0400 +@@ -402,12 +402,19 @@ static inline void task_seccomp(struct s + seq_putc(m, '\n'); + } + ++#include + static inline void task_context_switch_counts(struct seq_file *m, + struct task_struct *p) + { ++ int *newpid; ++ + seq_put_decimal_ull(m, "voluntary_ctxt_switches:\t", p->nvcsw); + seq_put_decimal_ull(m, "\nnonvoluntary_ctxt_switches:\t", p->nivcsw); + seq_putc(m, '\n'); ++ ++ newpid = klp_shadow_get(p, 0); ++ 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 2022-04-29 15:52:13.577336397 -0400 ++++ src/kernel/exit.c 2022-04-29 15:53:13.252548763 -0400 +@@ -725,6 +725,7 @@ static void check_stack_usage(void) + static inline void check_stack_usage(void) {} + #endif + ++#include + void __noreturn do_exit(long code) + { + struct task_struct *tsk = current; +@@ -826,6 +827,8 @@ void __noreturn do_exit(long code) + exit_task_work(tsk); + exit_thread(tsk); + ++ klp_shadow_free(tsk, 0, NULL); ++ + /* + * 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 2022-04-29 15:52:13.577336397 -0400 ++++ src/kernel/fork.c 2022-04-29 15:53:13.252548763 -0400 +@@ -2540,6 +2540,7 @@ struct task_struct *create_io_thread(int + * + * args->exit_signal is expected to be checked for sanity by the caller. + */ ++#include + pid_t kernel_clone(struct kernel_clone_args *args) + { + u64 clone_flags = args->flags; +@@ -2548,6 +2549,8 @@ pid_t kernel_clone(struct kernel_clone_a + struct task_struct *p; + int trace = 0; + pid_t nr; ++ int *newpid; ++ static int ctr = 0; + + /* + * For legacy clone() calls, CLONE_PIDFD uses the parent_tid argument +@@ -2587,6 +2590,11 @@ pid_t kernel_clone(struct kernel_clone_a + if (IS_ERR(p)) + return PTR_ERR(p); + ++ newpid = klp_shadow_get_or_alloc(p, 0, sizeof(*newpid), GFP_KERNEL, ++ NULL, NULL); ++ if (newpid) ++ *newpid = ctr++; ++ + /* + * Do this prior waking up the new thread - the thread pointer + * might get invalid after that point, if the thread exits quickly. diff --git a/test/integration/rhel-9.0/smp-locks-section.patch b/test/integration/rhel-9.0/smp-locks-section.patch new file mode 100644 index 0000000..32f3086 --- /dev/null +++ b/test/integration/rhel-9.0/smp-locks-section.patch @@ -0,0 +1,13 @@ +diff -Nupr src.orig/drivers/tty/tty_buffer.c src/drivers/tty/tty_buffer.c +--- src.orig/drivers/tty/tty_buffer.c 2022-04-29 15:52:13.275335322 -0400 ++++ src/drivers/tty/tty_buffer.c 2022-04-29 15:53:16.055558738 -0400 +@@ -263,6 +263,9 @@ static int __tty_buffer_request_room(str + struct tty_buffer *b, *n; + int left, change; + ++ if (!size) ++ printk("kpatch-test: testing .smp_locks section changes\n"); ++ + b = buf->tail; + if (b->flags & TTYB_NORMAL) + left = 2 * b->size - b->used; diff --git a/test/integration/rhel-9.0/special-static.patch b/test/integration/rhel-9.0/special-static.patch new file mode 100644 index 0000000..79d333f --- /dev/null +++ b/test/integration/rhel-9.0/special-static.patch @@ -0,0 +1,22 @@ +diff -Nupr src.orig/kernel/fork.c src/kernel/fork.c +--- src.orig/kernel/fork.c 2022-04-29 15:52:13.577336397 -0400 ++++ src/kernel/fork.c 2022-04-29 15:53:18.857568709 -0400 +@@ -1635,10 +1635,18 @@ static void posix_cpu_timers_init_group( + posix_cputimers_group_init(pct, cpu_limit); + } + ++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; + diff --git a/test/integration/rhel-9.0/symvers-disagreement-FAIL.patch b/test/integration/rhel-9.0/symvers-disagreement-FAIL.patch new file mode 100644 index 0000000..0c91065 --- /dev/null +++ b/test/integration/rhel-9.0/symvers-disagreement-FAIL.patch @@ -0,0 +1,46 @@ +From 2d6b7bce089e52563bd9c67df62f48e90b48047d Mon Sep 17 00:00:00 2001 +From: Julien Thierry +Date: Wed, 6 May 2020 14:30:57 +0100 +Subject: [PATCH] Symbol version change + +This change causes: +1) Some exported symbols in drivers/base/core.c to see their CRCs + change. +2) Changes usb_get_dev() referencing a get_device() whose CRC has + changed, causing the symbol and the new CRC to be included in the + __version section of the final module. + +This makes the final module unloadable for the target kernel. + +See "Exported symbol versioning" of the patch author guide for more +detail. + +--- + drivers/base/core.c | 2 ++ + drivers/usb/core/usb.c | 2 ++ + 2 files changed, 4 insertions(+) + +diff -Nupr src.orig/drivers/base/core.c src/drivers/base/core.c +--- src.orig/drivers/base/core.c 2022-04-29 15:52:12.115331194 -0400 ++++ src/drivers/base/core.c 2022-04-29 15:53:21.690578791 -0400 +@@ -34,6 +34,8 @@ + #include "base.h" + #include "power/power.h" + ++#include ++ + #ifdef CONFIG_SYSFS_DEPRECATED + #ifdef CONFIG_SYSFS_DEPRECATED_V2 + long sysfs_deprecated = 1; +diff -Nupr src.orig/drivers/usb/core/usb.c src/drivers/usb/core/usb.c +--- src.orig/drivers/usb/core/usb.c 2022-04-29 15:52:13.286335361 -0400 ++++ src/drivers/usb/core/usb.c 2022-04-29 15:53:21.690578791 -0400 +@@ -739,6 +739,8 @@ EXPORT_SYMBOL_GPL(usb_alloc_dev); + */ + struct usb_device *usb_get_dev(struct usb_device *dev) + { ++ barrier(); ++ + if (dev) + get_device(&dev->dev); + return dev; diff --git a/test/integration/rhel-9.0/syscall.patch b/test/integration/rhel-9.0/syscall.patch new file mode 100644 index 0000000..623f2d9 --- /dev/null +++ b/test/integration/rhel-9.0/syscall.patch @@ -0,0 +1,20 @@ +diff -Nupr src.orig/kernel/sys.c src/kernel/sys.c +--- src.orig/kernel/sys.c 2022-04-29 15:56:57.808347857 -0400 ++++ src/kernel/sys.c 2022-04-29 15:56:58.373349868 -0400 +@@ -1268,13 +1268,15 @@ static int override_release(char __user + return ret; + } + +-SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) ++#include "kpatch-syscall.h" ++KPATCH_SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) + { + struct new_utsname tmp; + + down_read(&uts_sem); + memcpy(&tmp, utsname(), sizeof(tmp)); + up_read(&uts_sem); ++ strcat(tmp.sysname, ".kpatch"); + if (copy_to_user(name, &tmp, sizeof(tmp))) + return -EFAULT; + diff --git a/test/integration/rhel-9.0/tracepoints-section.patch b/test/integration/rhel-9.0/tracepoints-section.patch new file mode 100644 index 0000000..c8a0c71 --- /dev/null +++ b/test/integration/rhel-9.0/tracepoints-section.patch @@ -0,0 +1,18 @@ +diff -Nupr src.orig/kernel/time/timer.c src/kernel/time/timer.c +--- src.orig/kernel/time/timer.c 2022-04-29 15:52:13.591336446 -0400 ++++ src/kernel/time/timer.c 2022-04-29 15:53:24.467588674 -0400 +@@ -1740,10 +1740,14 @@ static inline void __run_timers(struct t + /* + * This function runs timers and the timer-tq in bottom half context. + */ ++__attribute__((optimize("-fno-optimize-sibling-calls"))) + static __latent_entropy void run_timer_softirq(struct softirq_action *h) + { + struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]); + ++ if (!base) ++ printk("kpatch-test: testing __tracepoints section changes\n"); ++ + __run_timers(base); + if (IS_ENABLED(CONFIG_NO_HZ_COMMON)) + __run_timers(this_cpu_ptr(&timer_bases[BASE_DEF])); diff --git a/test/integration/rhel-9.0/warn-detect-FAIL.patch b/test/integration/rhel-9.0/warn-detect-FAIL.patch new file mode 100644 index 0000000..dc5a470 --- /dev/null +++ b/test/integration/rhel-9.0/warn-detect-FAIL.patch @@ -0,0 +1,9 @@ +diff -Nupr src.orig/arch/x86/kvm/x86.c src/arch/x86/kvm/x86.c +--- src.orig/arch/x86/kvm/x86.c 2022-04-29 15:52:12.045330945 -0400 ++++ src/arch/x86/kvm/x86.c 2022-04-29 15:53:27.283598695 -0400 +@@ -1,4 +1,5 @@ + // SPDX-License-Identifier: GPL-2.0-only ++ + /* + * Kernel-based Virtual Machine driver for Linux + * From 4774d070d240af077cff3a77fc6e852cd9a570ff Mon Sep 17 00:00:00 2001 From: Joe Lawrence Date: Fri, 6 May 2022 14:42:11 -0400 Subject: [PATCH 2/2] test/integration/rhel-9.0: remove obsolete tests Clean out any integration tests that no longer exercise their original use cases. Suggested-by: Josh Poimboeuf Signed-off-by: Joe Lawrence --- .../rhel-9.0/bug-table-section.patch | 12 -- .../rhel-9.0/cmdline-string-LOADED.test | 3 - .../integration/rhel-9.0/cmdline-string.patch | 13 -- .../rhel-9.0/data-read-mostly.patch | 11 -- test/integration/rhel-9.0/fixup-section.patch | 11 -- test/integration/rhel-9.0/gcc-isra.patch | 11 -- test/integration/rhel-9.0/gcc-mangled-3.patch | 13 -- .../rhel-9.0/gcc-static-local-var-2.patch | 13 -- .../rhel-9.0/gcc-static-local-var-3.patch | 19 -- .../rhel-9.0/gcc-static-local-var-4.patch | 22 --- .../rhel-9.0/gcc-static-local-var-4.test | 8 - .../rhel-9.0/gcc-static-local-var-5.patch | 69 -------- test/integration/rhel-9.0/macro-printk.patch | 165 ------------------ .../rhel-9.0/meminfo-init-FAIL.patch | 11 -- .../rhel-9.0/meminfo-init2-FAIL.patch | 19 -- .../rhel-9.0/meminfo-string-LOADED.test | 3 - .../integration/rhel-9.0/meminfo-string.patch | 12 -- .../rhel-9.0/parainstructions-section.patch | 11 -- .../rhel-9.0/smp-locks-section.patch | 13 -- .../rhel-9.0/tracepoints-section.patch | 18 -- 20 files changed, 457 deletions(-) delete mode 100644 test/integration/rhel-9.0/bug-table-section.patch delete mode 100755 test/integration/rhel-9.0/cmdline-string-LOADED.test delete mode 100644 test/integration/rhel-9.0/cmdline-string.patch delete mode 100644 test/integration/rhel-9.0/data-read-mostly.patch delete mode 100644 test/integration/rhel-9.0/fixup-section.patch delete mode 100644 test/integration/rhel-9.0/gcc-isra.patch delete mode 100644 test/integration/rhel-9.0/gcc-mangled-3.patch delete mode 100644 test/integration/rhel-9.0/gcc-static-local-var-2.patch delete mode 100644 test/integration/rhel-9.0/gcc-static-local-var-3.patch delete mode 100644 test/integration/rhel-9.0/gcc-static-local-var-4.patch delete mode 100755 test/integration/rhel-9.0/gcc-static-local-var-4.test delete mode 100644 test/integration/rhel-9.0/gcc-static-local-var-5.patch delete mode 100644 test/integration/rhel-9.0/macro-printk.patch delete mode 100644 test/integration/rhel-9.0/meminfo-init-FAIL.patch delete mode 100644 test/integration/rhel-9.0/meminfo-init2-FAIL.patch delete mode 100755 test/integration/rhel-9.0/meminfo-string-LOADED.test delete mode 100644 test/integration/rhel-9.0/meminfo-string.patch delete mode 100644 test/integration/rhel-9.0/parainstructions-section.patch delete mode 100644 test/integration/rhel-9.0/smp-locks-section.patch delete mode 100644 test/integration/rhel-9.0/tracepoints-section.patch diff --git a/test/integration/rhel-9.0/bug-table-section.patch b/test/integration/rhel-9.0/bug-table-section.patch deleted file mode 100644 index 714bfb0..0000000 --- a/test/integration/rhel-9.0/bug-table-section.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -Nupr src.orig/fs/proc/proc_sysctl.c src/fs/proc/proc_sysctl.c ---- src.orig/fs/proc/proc_sysctl.c 2022-04-29 15:52:13.400335767 -0400 -+++ src/fs/proc/proc_sysctl.c 2022-04-29 15:52:14.157338461 -0400 -@@ -302,6 +302,8 @@ static void start_unregistering(struct c - - 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)) diff --git a/test/integration/rhel-9.0/cmdline-string-LOADED.test b/test/integration/rhel-9.0/cmdline-string-LOADED.test deleted file mode 100755 index a8e0a08..0000000 --- a/test/integration/rhel-9.0/cmdline-string-LOADED.test +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -grep kpatch=1 /proc/cmdline diff --git a/test/integration/rhel-9.0/cmdline-string.patch b/test/integration/rhel-9.0/cmdline-string.patch deleted file mode 100644 index 871d61f..0000000 --- a/test/integration/rhel-9.0/cmdline-string.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff -Nupr src.orig/fs/proc/cmdline.c src/fs/proc/cmdline.c ---- src.orig/fs/proc/cmdline.c 2022-04-29 15:52:13.399335763 -0400 -+++ src/fs/proc/cmdline.c 2022-04-29 15:52:17.041348724 -0400 -@@ -6,8 +6,7 @@ - - static int cmdline_proc_show(struct seq_file *m, void *v) - { -- seq_puts(m, saved_command_line); -- seq_putc(m, '\n'); -+ seq_printf(m, "%s kpatch=1\n", saved_command_line); - return 0; - } - diff --git a/test/integration/rhel-9.0/data-read-mostly.patch b/test/integration/rhel-9.0/data-read-mostly.patch deleted file mode 100644 index 194d728..0000000 --- a/test/integration/rhel-9.0/data-read-mostly.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -Nupr src.orig/net/core/dev.c src/net/core/dev.c ---- src.orig/net/core/dev.c 2022-04-29 15:52:13.627336575 -0400 -+++ src/net/core/dev.c 2022-04-29 15:52:22.819369286 -0400 -@@ -5405,6 +5405,7 @@ skip_classify: - case RX_HANDLER_PASS: - break; - default: -+ printk("BUG!\n"); - BUG(); - } - } diff --git a/test/integration/rhel-9.0/fixup-section.patch b/test/integration/rhel-9.0/fixup-section.patch deleted file mode 100644 index a163177..0000000 --- a/test/integration/rhel-9.0/fixup-section.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -Nupr src.orig/fs/readdir.c src/fs/readdir.c ---- src.orig/fs/readdir.c 2022-04-29 15:52:13.347335578 -0400 -+++ src/fs/readdir.c 2022-04-29 15:52:25.604379197 -0400 -@@ -245,6 +245,7 @@ static int filldir(struct dir_context *c - if (prev_reclen && signal_pending(current)) - return -EINTR; - dirent = buf->current_dir; -+ asm("nop"); - prev = (void __user *) dirent - prev_reclen; - if (!user_write_access_begin(prev, reclen + prev_reclen)) - goto efault; diff --git a/test/integration/rhel-9.0/gcc-isra.patch b/test/integration/rhel-9.0/gcc-isra.patch deleted file mode 100644 index 8a6c17b..0000000 --- a/test/integration/rhel-9.0/gcc-isra.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -Nupr src.orig/fs/proc/proc_sysctl.c src/fs/proc/proc_sysctl.c ---- src.orig/fs/proc/proc_sysctl.c 2022-04-29 15:52:13.400335767 -0400 -+++ src/fs/proc/proc_sysctl.c 2022-04-29 15:52:28.391389115 -0400 -@@ -55,6 +55,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); - } diff --git a/test/integration/rhel-9.0/gcc-mangled-3.patch b/test/integration/rhel-9.0/gcc-mangled-3.patch deleted file mode 100644 index 7be534b..0000000 --- a/test/integration/rhel-9.0/gcc-mangled-3.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff -Nupr src.orig/mm/slub.c src/mm/slub.c ---- src.orig/mm/slub.c 2022-04-29 15:52:13.612336521 -0400 -+++ src/mm/slub.c 2022-04-29 15:52:31.210399147 -0400 -@@ -6222,6 +6222,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); diff --git a/test/integration/rhel-9.0/gcc-static-local-var-2.patch b/test/integration/rhel-9.0/gcc-static-local-var-2.patch deleted file mode 100644 index 34bdbec..0000000 --- a/test/integration/rhel-9.0/gcc-static-local-var-2.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff -Nupr src.orig/mm/mmap.c src/mm/mmap.c ---- src.orig/mm/mmap.c 2022-04-29 15:52:13.610336514 -0400 -+++ src/mm/mmap.c 2022-04-29 15:52:34.000409076 -0400 -@@ -1723,6 +1723,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, vm_flags, len >> PAGE_SHIFT)) { - unsigned long nr_pages; diff --git a/test/integration/rhel-9.0/gcc-static-local-var-3.patch b/test/integration/rhel-9.0/gcc-static-local-var-3.patch deleted file mode 100644 index 0b201ff..0000000 --- a/test/integration/rhel-9.0/gcc-static-local-var-3.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff -Nupr src.orig/kernel/reboot.c src/kernel/reboot.c ---- src.orig/kernel/reboot.c 2022-04-29 15:52:13.578336400 -0400 -+++ src/kernel/reboot.c 2022-04-29 15:52:36.769418930 -0400 -@@ -397,8 +397,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); - } - diff --git a/test/integration/rhel-9.0/gcc-static-local-var-4.patch b/test/integration/rhel-9.0/gcc-static-local-var-4.patch deleted file mode 100644 index 5c2173c..0000000 --- a/test/integration/rhel-9.0/gcc-static-local-var-4.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff -Nupr src.orig/fs/aio.c src/fs/aio.c ---- src.orig/fs/aio.c 2022-04-29 15:52:13.345335571 -0400 -+++ src/fs/aio.c 2022-04-29 15:52:39.560428863 -0400 -@@ -278,11 +278,18 @@ 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; - struct address_space *i_mapping; - -+ kpatch_aio_foo(); - if (aio_ring_file) { - truncate_setsize(file_inode(aio_ring_file), 0); - diff --git a/test/integration/rhel-9.0/gcc-static-local-var-4.test b/test/integration/rhel-9.0/gcc-static-local-var-4.test deleted file mode 100755 index e085f93..0000000 --- a/test/integration/rhel-9.0/gcc-static-local-var-4.test +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -set -o pipefail -if ! $(eu-readelf --wide --symbols test-gcc-static-local-var-4.ko | awk '$NF == "free_ioctx" { exit 1 }'); then - exit 1 -else - exit 0 -fi diff --git a/test/integration/rhel-9.0/gcc-static-local-var-5.patch b/test/integration/rhel-9.0/gcc-static-local-var-5.patch deleted file mode 100644 index 07d9183..0000000 --- a/test/integration/rhel-9.0/gcc-static-local-var-5.patch +++ /dev/null @@ -1,69 +0,0 @@ -diff -Nupr src.orig/kernel/audit.c src/kernel/audit.c ---- src.orig/kernel/audit.c 2022-04-29 15:52:13.576336393 -0400 -+++ src/kernel/audit.c 2022-04-29 15:52:42.384438912 -0400 -@@ -314,6 +314,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; -@@ -324,6 +330,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); -@@ -343,6 +350,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 -@@ -389,6 +401,8 @@ static int audit_log_config_change(char - struct audit_buffer *ab; - int rc = 0; - -+ kpatch_audit_check(); -+ - ab = audit_log_start(audit_context(), GFP_KERNEL, AUDIT_CONFIG_CHANGE); - if (unlikely(!ab)) - return rc; -@@ -1095,6 +1109,7 @@ static int audit_get_feature(struct sk_b - return 0; - } - -+__attribute__((optimize("-fno-optimize-sibling-calls"))) - static void audit_log_feature_change(int which, u32 old_feature, u32 new_feature, - u32 old_lock, u32 new_lock, int res) - { -@@ -2230,6 +2245,7 @@ EXPORT_SYMBOL(audit_log_task_info); - * @type: audit message type (AUDIT_ANOM_LINK, AUDIT_ANOM_CREAT, etc) - * @operation: specific operation name - */ -+__attribute__((optimize("-fno-optimize-sibling-calls"))) - void audit_log_path_denied(int type, const char *operation) - { - struct audit_buffer *ab; -@@ -2368,6 +2384,7 @@ int audit_signal_info(int sig, struct ta - * queue and a kthread is scheduled to remove them from the queue outside the - * irq context. May be called in any context. - */ -+__attribute__((optimize("-fno-optimize-sibling-calls"))) - void audit_log_end(struct audit_buffer *ab) - { - struct sk_buff *skb; diff --git a/test/integration/rhel-9.0/macro-printk.patch b/test/integration/rhel-9.0/macro-printk.patch deleted file mode 100644 index 77c3ddf..0000000 --- a/test/integration/rhel-9.0/macro-printk.patch +++ /dev/null @@ -1,165 +0,0 @@ -diff -Nupr src.orig/net/ipv4/fib_frontend.c src/net/ipv4/fib_frontend.c ---- src.orig/net/ipv4/fib_frontend.c 2022-04-29 15:52:13.635336603 -0400 -+++ src/net/ipv4/fib_frontend.c 2022-04-29 15:52:50.873469122 -0400 -@@ -865,6 +865,7 @@ errout: - return err; - } - -+#include "kpatch-macros.h" - static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, - struct netlink_ext_ack *extack) - { -@@ -886,6 +887,7 @@ static int inet_rtm_newroute(struct sk_b - err = fib_table_insert(net, tb, &cfg, extack); - if (!err && cfg.fc_type == RTN_LOCAL) - net->ipv4.fib_has_custom_local_routes = true; -+ 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 2022-04-29 15:52:13.635336603 -0400 -+++ src/net/ipv4/fib_semantics.c 2022-04-29 15:52:50.873469122 -0400 -@@ -1342,6 +1342,7 @@ static bool fib_valid_prefsrc(struct fib - return true; - } - -+#include "kpatch-macros.h" - struct fib_info *fib_create_info(struct fib_config *cfg, - struct netlink_ext_ack *extack) - { -@@ -1393,6 +1394,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; -@@ -1413,6 +1415,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(struct_size(fi, fib_nh, nhs), GFP_KERNEL); - if (!fi) -@@ -1426,6 +1429,8 @@ struct fib_info *fib_create_info(struct - } - - 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; - fi->fib_scope = cfg->fc_scope; -@@ -1452,13 +1457,18 @@ struct fib_info *fib_create_info(struct - if (cfg->fc_mp) - err = fib_get_nhs(fi, cfg->fc_mp, cfg->fc_mp_len, cfg, - extack); -- else -+ else { -+ KPATCH_PRINTK("[fib_create_info]: 4 create error err is %d\n",err); - err = fib_nh_init(net, fi->fib_nh, cfg, 1, extack); -+ KPATCH_PRINTK("[fib_create_info]: 5 create error err is %d\n",err); -+ } - } - - if (err != 0) - goto failure; - -+ KPATCH_PRINTK("[fib_create_info]: 6 create error err is %d\n",err); -+ - if (fib_props[cfg->fc_type].error) { - if (cfg->fc_gw_family || cfg->fc_oif || cfg->fc_mp) { - NL_SET_ERR_MSG(extack, -@@ -1479,6 +1489,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) { - NL_SET_ERR_MSG(extack, "Invalid scope"); -@@ -1523,6 +1534,7 @@ struct fib_info *fib_create_info(struct - if (linkdown == fi->fib_nhs) - fi->fib_flags |= RTNH_F_LINKDOWN; - } -+ KPATCH_PRINTK("[fib_create_info]: 8 create error err is %d\n",err); - - if (fi->fib_prefsrc && !fib_valid_prefsrc(cfg, fi->fib_prefsrc)) { - NL_SET_ERR_MSG(extack, "Invalid prefsrc address"); -@@ -1536,6 +1548,7 @@ struct fib_info *fib_create_info(struct - if (nexthop_nh->fib_nh_gw_family == AF_INET6) - fi->fib_nh_is_v6 = true; - } endfor_nexthops(fi) -+ KPATCH_PRINTK("[fib_create_info]: 9 create error err is %d\n",err); - - fib_rebalance(fi); - } -@@ -1548,6 +1561,7 @@ link_it: - ofi->fib_treeref++; - return ofi; - } -+ KPATCH_PRINTK("[fib_create_info]: 10 create error err is %d\n",err); - - fi->fib_treeref++; - refcount_set(&fi->fib_clntref, 1); -@@ -1575,6 +1589,7 @@ link_it: - } 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: -@@ -1585,6 +1600,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 2022-04-29 15:52:13.635336603 -0400 -+++ src/net/ipv4/fib_trie.c 2022-04-29 15:52:50.874469126 -0400 -@@ -532,6 +532,7 @@ static struct key_vector *replace(struct - return tp; - } - -+__attribute__((optimize("-fno-optimize-sibling-calls"))) - static struct key_vector *inflate(struct trie *t, - struct key_vector *oldtnode) - { -@@ -628,6 +629,7 @@ notnode: - return NULL; - } - -+__attribute__((optimize("-fno-optimize-sibling-calls"))) - static struct key_vector *halve(struct trie *t, - struct key_vector *oldtnode) - { -@@ -1200,6 +1202,7 @@ static void fib_remove_alias(struct trie - struct key_vector *l, struct fib_alias *old); - - /* Caller must hold RTNL. */ -+#include "kpatch-macros.h" - int fib_table_insert(struct net *net, struct fib_table *tb, - struct fib_config *cfg, struct netlink_ext_ack *extack) - { -@@ -1221,11 +1224,14 @@ int fib_table_insert(struct net *net, st - - pr_debug("Insert table=%u %08x/%d\n", tb->tb_id, key, plen); - -+ KPATCH_PRINTK("[fib_table_insert]: start\n"); - fi = fib_create_info(cfg, extack); - 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, diff --git a/test/integration/rhel-9.0/meminfo-init-FAIL.patch b/test/integration/rhel-9.0/meminfo-init-FAIL.patch deleted file mode 100644 index 95e5472..0000000 --- a/test/integration/rhel-9.0/meminfo-init-FAIL.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c ---- src.orig/fs/proc/meminfo.c 2022-04-29 15:52:13.399335763 -0400 -+++ src/fs/proc/meminfo.c 2022-04-29 15:52:56.486489097 -0400 -@@ -155,6 +155,7 @@ static int meminfo_proc_show(struct seq_ - - static int __init proc_meminfo_init(void) - { -+ printk("a\n"); - proc_create_single("meminfo", 0, NULL, meminfo_proc_show); - return 0; - } diff --git a/test/integration/rhel-9.0/meminfo-init2-FAIL.patch b/test/integration/rhel-9.0/meminfo-init2-FAIL.patch deleted file mode 100644 index 7f64d0f..0000000 --- a/test/integration/rhel-9.0/meminfo-init2-FAIL.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c ---- src.orig/fs/proc/meminfo.c 2022-04-29 15:52:13.399335763 -0400 -+++ src/fs/proc/meminfo.c 2022-04-29 15:52:53.660479040 -0400 -@@ -39,6 +39,7 @@ static int meminfo_proc_show(struct seq_ - unsigned long sreclaimable, sunreclaim; - int lru; - -+ printk("a\n"); - si_meminfo(&i); - si_swapinfo(&i); - committed = vm_memory_committed(); -@@ -155,6 +156,7 @@ static int meminfo_proc_show(struct seq_ - - static int __init proc_meminfo_init(void) - { -+ printk("a\n"); - proc_create_single("meminfo", 0, NULL, meminfo_proc_show); - return 0; - } diff --git a/test/integration/rhel-9.0/meminfo-string-LOADED.test b/test/integration/rhel-9.0/meminfo-string-LOADED.test deleted file mode 100755 index 10dc20b..0000000 --- a/test/integration/rhel-9.0/meminfo-string-LOADED.test +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -grep VMALLOCCHUNK /proc/meminfo diff --git a/test/integration/rhel-9.0/meminfo-string.patch b/test/integration/rhel-9.0/meminfo-string.patch deleted file mode 100644 index 77d41e5..0000000 --- a/test/integration/rhel-9.0/meminfo-string.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c ---- src.orig/fs/proc/meminfo.c 2022-04-29 15:52:13.399335763 -0400 -+++ src/fs/proc/meminfo.c 2022-04-29 15:52:59.251498937 -0400 -@@ -119,7 +119,7 @@ static int meminfo_proc_show(struct seq_ - seq_printf(m, "VmallocTotal: %8lu kB\n", - (unsigned long)VMALLOC_TOTAL >> 10); - show_val_kb(m, "VmallocUsed: ", vmalloc_nr_pages()); -- show_val_kb(m, "VmallocChunk: ", 0ul); -+ show_val_kb(m, "VMALLOCCHUNK: ", 0ul); - show_val_kb(m, "Percpu: ", pcpu_nr_pages()); - - #ifdef CONFIG_MEMORY_FAILURE diff --git a/test/integration/rhel-9.0/parainstructions-section.patch b/test/integration/rhel-9.0/parainstructions-section.patch deleted file mode 100644 index 4d7c8e5..0000000 --- a/test/integration/rhel-9.0/parainstructions-section.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -Nupr src.orig/fs/proc/generic.c src/fs/proc/generic.c ---- src.orig/fs/proc/generic.c 2022-04-29 15:52:13.399335763 -0400 -+++ src/fs/proc/generic.c 2022-04-29 15:53:10.475538880 -0400 -@@ -203,6 +203,7 @@ int proc_alloc_inum(unsigned int *inum) - { - int i; - -+ printk("kpatch-test: testing change to .parainstructions section\n"); - i = ida_simple_get(&proc_inum_ida, 0, UINT_MAX - PROC_DYNAMIC_FIRST + 1, - GFP_KERNEL); - if (i < 0) diff --git a/test/integration/rhel-9.0/smp-locks-section.patch b/test/integration/rhel-9.0/smp-locks-section.patch deleted file mode 100644 index 32f3086..0000000 --- a/test/integration/rhel-9.0/smp-locks-section.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff -Nupr src.orig/drivers/tty/tty_buffer.c src/drivers/tty/tty_buffer.c ---- src.orig/drivers/tty/tty_buffer.c 2022-04-29 15:52:13.275335322 -0400 -+++ src/drivers/tty/tty_buffer.c 2022-04-29 15:53:16.055558738 -0400 -@@ -263,6 +263,9 @@ static int __tty_buffer_request_room(str - struct tty_buffer *b, *n; - int left, change; - -+ if (!size) -+ printk("kpatch-test: testing .smp_locks section changes\n"); -+ - b = buf->tail; - if (b->flags & TTYB_NORMAL) - left = 2 * b->size - b->used; diff --git a/test/integration/rhel-9.0/tracepoints-section.patch b/test/integration/rhel-9.0/tracepoints-section.patch deleted file mode 100644 index c8a0c71..0000000 --- a/test/integration/rhel-9.0/tracepoints-section.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff -Nupr src.orig/kernel/time/timer.c src/kernel/time/timer.c ---- src.orig/kernel/time/timer.c 2022-04-29 15:52:13.591336446 -0400 -+++ src/kernel/time/timer.c 2022-04-29 15:53:24.467588674 -0400 -@@ -1740,10 +1740,14 @@ static inline void __run_timers(struct t - /* - * This function runs timers and the timer-tq in bottom half context. - */ -+__attribute__((optimize("-fno-optimize-sibling-calls"))) - static __latent_entropy void run_timer_softirq(struct softirq_action *h) - { - struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]); - -+ if (!base) -+ printk("kpatch-test: testing __tracepoints section changes\n"); -+ - __run_timers(base); - if (IS_ENABLED(CONFIG_NO_HZ_COMMON)) - __run_timers(this_cpu_ptr(&timer_bases[BASE_DEF]));