Skip to content

Commit 5dcc40b

Browse files
committed
test/integration/rhel-9.5: add tests for kernel-5.14.0-503.11.1.el9_5
Signed-off-by: Ryan Sullivan <[email protected]>
1 parent 17b795b commit 5dcc40b

14 files changed

+450
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
grep "kpatch: 5" /proc/meminfo
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c
2+
--- src.orig/fs/proc/meminfo.c 2024-10-30 13:11:05.778615433 -0400
3+
+++ src/fs/proc/meminfo.c 2024-10-30 13:11:06.647613918 -0400
4+
@@ -31,6 +31,8 @@ static void show_val_kb(struct seq_file
5+
seq_write(m, " kB\n", 4);
6+
}
7+
8+
+static int foo = 5;
9+
+
10+
static int meminfo_proc_show(struct seq_file *m, void *v)
11+
{
12+
struct sysinfo i;
13+
@@ -168,6 +170,7 @@ static int meminfo_proc_show(struct seq_
14+
show_val_kb(m, "CmaFree: ",
15+
global_zone_page_state(NR_FREE_CMA_PAGES));
16+
#endif
17+
+ seq_printf(m, "kpatch: %d\n", foo);
18+
19+
#ifdef CONFIG_UNACCEPTED_MEMORY
20+
show_val_kb(m, "Unaccepted: ",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff -Nupr src.orig/net/ipv6/netfilter.c src/net/ipv6/netfilter.c
2+
--- src.orig/net/ipv6/netfilter.c 2024-10-30 13:11:06.032614990 -0400
3+
+++ src/net/ipv6/netfilter.c 2024-10-30 13:11:15.536598418 -0400
4+
@@ -97,6 +97,8 @@ static int nf_ip6_reroute(struct sk_buff
5+
return 0;
6+
}
7+
8+
+#include "kpatch-macros.h"
9+
+
10+
int __nf_ip6_route(struct net *net, struct dst_entry **dst,
11+
struct flowi *fl, bool strict)
12+
{
13+
@@ -110,6 +112,9 @@ int __nf_ip6_route(struct net *net, stru
14+
struct dst_entry *result;
15+
int err;
16+
17+
+ if (!jiffies)
18+
+ printk("kpatch nf_ip6_route foo\n");
19+
+
20+
result = ip6_route_output(net, sk, &fl->u.ip6);
21+
err = result->error;
22+
if (err)
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
diff -Nupr src.orig/drivers/input/joydev.c src/drivers/input/joydev.c
2+
--- src.orig/drivers/input/joydev.c 2024-10-30 13:11:05.315616240 -0400
3+
+++ src/drivers/input/joydev.c 2024-10-30 13:11:17.882594327 -0400
4+
@@ -1096,3 +1096,47 @@ static void __exit joydev_exit(void)
5+
6+
module_init(joydev_init);
7+
module_exit(joydev_exit);
8+
+
9+
+#include <linux/module.h>
10+
+#include "kpatch-macros.h"
11+
+
12+
+static const char *const module_state[] = {
13+
+ [MODULE_STATE_LIVE] = "[MODULE_STATE_LIVE] Normal state",
14+
+ [MODULE_STATE_COMING] = "[MODULE_STATE_COMING] Full formed, running module_init",
15+
+ [MODULE_STATE_GOING] = "[MODULE_STATE_GOING] Going away",
16+
+ [MODULE_STATE_UNFORMED] = "[MODULE_STATE_UNFORMED] Still setting it up",
17+
+};
18+
+
19+
+static void callback_info(const char *callback, patch_object *obj)
20+
+{
21+
+ if (obj->mod)
22+
+ pr_info("%s: %s -> %s\n", callback, obj->mod->name,
23+
+ module_state[obj->mod->state]);
24+
+ else
25+
+ pr_info("%s: vmlinux\n", callback);
26+
+}
27+
+
28+
+static int pre_patch_callback(patch_object *obj)
29+
+{
30+
+ callback_info(__func__, obj);
31+
+ return 0; /* return -ENODEV; */
32+
+}
33+
+KPATCH_PRE_PATCH_CALLBACK(pre_patch_callback);
34+
+
35+
+static void post_patch_callback(patch_object *obj)
36+
+{
37+
+ callback_info(__func__, obj);
38+
+}
39+
+KPATCH_POST_PATCH_CALLBACK(post_patch_callback);
40+
+
41+
+static void pre_unpatch_callback(patch_object *obj)
42+
+{
43+
+ callback_info(__func__, obj);
44+
+}
45+
+KPATCH_PRE_UNPATCH_CALLBACK(pre_unpatch_callback);
46+
+
47+
+static void post_unpatch_callback(patch_object *obj)
48+
+{
49+
+ callback_info(__func__, obj);
50+
+}
51+
+KPATCH_POST_UNPATCH_CALLBACK(post_unpatch_callback);
52+
diff -Nupr src.orig/drivers/input/misc/pcspkr.c src/drivers/input/misc/pcspkr.c
53+
--- src.orig/drivers/input/misc/pcspkr.c 2024-10-30 13:11:05.319616233 -0400
54+
+++ src/drivers/input/misc/pcspkr.c 2024-10-30 13:11:17.882594327 -0400
55+
@@ -134,3 +134,46 @@ static struct platform_driver pcspkr_pla
56+
};
57+
module_platform_driver(pcspkr_platform_driver);
58+
59+
+#include <linux/module.h>
60+
+#include "kpatch-macros.h"
61+
+
62+
+static const char *const module_state[] = {
63+
+ [MODULE_STATE_LIVE] = "[MODULE_STATE_LIVE] Normal state",
64+
+ [MODULE_STATE_COMING] = "[MODULE_STATE_COMING] Full formed, running module_init",
65+
+ [MODULE_STATE_GOING] = "[MODULE_STATE_GOING] Going away",
66+
+ [MODULE_STATE_UNFORMED] = "[MODULE_STATE_UNFORMED] Still setting it up",
67+
+};
68+
+
69+
+static void callback_info(const char *callback, patch_object *obj)
70+
+{
71+
+ if (obj->mod)
72+
+ pr_info("%s: %s -> %s\n", callback, obj->mod->name,
73+
+ module_state[obj->mod->state]);
74+
+ else
75+
+ pr_info("%s: vmlinux\n", callback);
76+
+}
77+
+
78+
+static int pre_patch_callback(patch_object *obj)
79+
+{
80+
+ callback_info(__func__, obj);
81+
+ return 0;
82+
+}
83+
+KPATCH_PRE_PATCH_CALLBACK(pre_patch_callback);
84+
+
85+
+static void post_patch_callback(patch_object *obj)
86+
+{
87+
+ callback_info(__func__, obj);
88+
+}
89+
+KPATCH_POST_PATCH_CALLBACK(post_patch_callback);
90+
+
91+
+static void pre_unpatch_callback(patch_object *obj)
92+
+{
93+
+ callback_info(__func__, obj);
94+
+}
95+
+KPATCH_PRE_UNPATCH_CALLBACK(pre_unpatch_callback);
96+
+
97+
+static void post_unpatch_callback(patch_object *obj)
98+
+{
99+
+ callback_info(__func__, obj);
100+
+}
101+
+KPATCH_POST_UNPATCH_CALLBACK(post_unpatch_callback);
102+
diff -Nupr src.orig/fs/aio.c src/fs/aio.c
103+
--- src.orig/fs/aio.c 2024-10-30 13:11:05.749615483 -0400
104+
+++ src/fs/aio.c 2024-10-30 13:11:17.882594327 -0400
105+
@@ -50,6 +50,50 @@
106+
107+
#define KIOCB_KEY 0
108+
109+
+#include <linux/module.h>
110+
+#include "kpatch-macros.h"
111+
+
112+
+static const char *const module_state[] = {
113+
+ [MODULE_STATE_LIVE] = "[MODULE_STATE_LIVE] Normal state",
114+
+ [MODULE_STATE_COMING] = "[MODULE_STATE_COMING] Full formed, running module_init",
115+
+ [MODULE_STATE_GOING] = "[MODULE_STATE_GOING] Going away",
116+
+ [MODULE_STATE_UNFORMED] = "[MODULE_STATE_UNFORMED] Still setting it up",
117+
+};
118+
+
119+
+static void callback_info(const char *callback, patch_object *obj)
120+
+{
121+
+ if (obj->mod)
122+
+ pr_info("%s: %s -> %s\n", callback, obj->mod->name,
123+
+ module_state[obj->mod->state]);
124+
+ else
125+
+ pr_info("%s: vmlinux\n", callback);
126+
+}
127+
+
128+
+static int pre_patch_callback(patch_object *obj)
129+
+{
130+
+ callback_info(__func__, obj);
131+
+ return 0;
132+
+}
133+
+KPATCH_PRE_PATCH_CALLBACK(pre_patch_callback);
134+
+
135+
+static void post_patch_callback(patch_object *obj)
136+
+{
137+
+ callback_info(__func__, obj);
138+
+}
139+
+KPATCH_POST_PATCH_CALLBACK(post_patch_callback);
140+
+
141+
+static void pre_unpatch_callback(patch_object *obj)
142+
+{
143+
+ callback_info(__func__, obj);
144+
+}
145+
+KPATCH_PRE_UNPATCH_CALLBACK(pre_unpatch_callback);
146+
+
147+
+static void post_unpatch_callback(patch_object *obj)
148+
+{
149+
+ callback_info(__func__, obj);
150+
+}
151+
+KPATCH_POST_UNPATCH_CALLBACK(post_unpatch_callback);
152+
+
153+
#define AIO_RING_MAGIC 0xa10a10a1
154+
#define AIO_RING_COMPAT_FEATURES 1
155+
#define AIO_RING_INCOMPAT_FEATURES 0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
5+
sudo modprobe nfsd
6+
sleep 5
7+
grep -q kpatch /proc/fs/nfs/exports
8+
9+
# TODO: This will trigger a printk on newer kernels which have the .klp.arch
10+
# removal. Don't actually do the grep until running on a newer kernel.
11+
echo "file fs/nfsd/export.c +p" > /sys/kernel/debug/dynamic_debug/control
12+
cat /proc/fs/nfs/exports > /dev/null
13+
# dmesg | grep -q "kpatch: pr_debug"
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
diff -Nupr src.orig/fs/nfsd/export.c src/fs/nfsd/export.c
2+
--- src.orig/fs/nfsd/export.c 2024-10-30 13:11:05.769615449 -0400
3+
+++ src/fs/nfsd/export.c 2024-10-30 13:11:20.262590177 -0400
4+
@@ -1356,6 +1356,10 @@ static void exp_flags(struct seq_file *m
5+
}
6+
}
7+
8+
+#include <linux/version.h>
9+
+extern char *kpatch_string(void);
10+
+
11+
+__attribute__((optimize("-fno-optimize-sibling-calls")))
12+
static int e_show(struct seq_file *m, void *p)
13+
{
14+
struct cache_head *cp = p;
15+
@@ -1363,12 +1367,36 @@ static int e_show(struct seq_file *m, vo
16+
struct cache_detail *cd = m->private;
17+
bool export_stats = is_export_stats_file(m);
18+
19+
+#ifdef CONFIG_X86_64
20+
+ alternative("ud2", "call single_task_running", X86_FEATURE_ALWAYS);
21+
+ alternative("call single_task_running", "ud2", X86_FEATURE_IA64);
22+
+
23+
+ slow_down_io(); /* paravirt call */
24+
+#endif
25+
+
26+
+ pr_debug("kpatch: pr_debug() test\n");
27+
+
28+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
29+
+{
30+
+ static DEFINE_STATIC_KEY_TRUE(kpatch_key);
31+
+
32+
+ if (static_branch_unlikely(&memcg_kmem_online_key))
33+
+ printk("kpatch: memcg_kmem_online_key\n");
34+
+
35+
+ BUG_ON(!static_branch_likely(&kpatch_key));
36+
+ static_branch_disable(&kpatch_key);
37+
+ BUG_ON(static_branch_likely(&kpatch_key));
38+
+ static_branch_enable(&kpatch_key);
39+
+}
40+
+#endif
41+
+
42+
if (p == SEQ_START_TOKEN) {
43+
seq_puts(m, "# Version 1.1\n");
44+
if (export_stats)
45+
seq_puts(m, "# Path Client Start-time\n#\tStats\n");
46+
else
47+
seq_puts(m, "# Path Client(Flags) # IPs\n");
48+
+ seq_puts(m, kpatch_string());
49+
return 0;
50+
}
51+
52+
diff -Nupr src.orig/net/netlink/af_netlink.c src/net/netlink/af_netlink.c
53+
--- src.orig/net/netlink/af_netlink.c 2024-10-30 13:11:06.044614969 -0400
54+
+++ src/net/netlink/af_netlink.c 2024-10-30 13:11:20.263590176 -0400
55+
@@ -2936,4 +2936,9 @@ panic:
56+
panic("netlink_init: Cannot allocate nl_table\n");
57+
}
58+
59+
+char *kpatch_string(void)
60+
+{
61+
+ return "# kpatch\n";
62+
+}
63+
+
64+
core_initcall(netlink_proto_init);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))"
4+
5+
declare -a blacklist=(meminfo-string-LOADED.test)
6+
7+
source ${SCRIPTDIR}/../common/multiple.template
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
diff -Nupr src.orig/fs/proc/cmdline.c src/fs/proc/cmdline.c
2+
--- src.orig/fs/proc/cmdline.c 2024-10-30 13:11:05.778615433 -0400
3+
+++ src/fs/proc/cmdline.c 2024-10-30 13:11:22.659585998 -0400
4+
@@ -17,3 +17,10 @@ static int __init proc_cmdline_init(void
5+
return 0;
6+
}
7+
fs_initcall(proc_cmdline_init);
8+
+
9+
+#include <linux/printk.h>
10+
+void kpatch_print_message(void)
11+
+{
12+
+ if (!jiffies)
13+
+ printk("hello there!\n");
14+
+}
15+
diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c
16+
--- src.orig/fs/proc/meminfo.c 2024-10-30 13:11:05.778615433 -0400
17+
+++ src/fs/proc/meminfo.c 2024-10-30 13:11:22.659585998 -0400
18+
@@ -21,6 +21,8 @@
19+
#include <asm/page.h>
20+
#include "internal.h"
21+
22+
+void kpatch_print_message(void);
23+
+
24+
void __attribute__((weak)) arch_report_meminfo(struct seq_file *m)
25+
{
26+
}
27+
@@ -57,6 +59,7 @@ static int meminfo_proc_show(struct seq_
28+
sreclaimable = global_node_page_state_pages(NR_SLAB_RECLAIMABLE_B);
29+
sunreclaim = global_node_page_state_pages(NR_SLAB_UNRECLAIMABLE_B);
30+
31+
+ kpatch_print_message();
32+
show_val_kb(m, "MemTotal: ", i.totalram);
33+
show_val_kb(m, "MemFree: ", i.freeram);
34+
show_val_kb(m, "MemAvailable: ", available);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
grep -q newpid: /proc/$$/status

0 commit comments

Comments
 (0)