mirror of https://github.com/dynup/kpatch
80 lines
2.3 KiB
Diff
80 lines
2.3 KiB
Diff
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 <jpoimboe@redhat.com>
|
|
|
|
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 <linux/version.h>
|
|
+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);
|
|
+
|
|
+ slow_down_io(); /* 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);
|