mirror of
https://github.com/dynup/kpatch
synced 2025-03-22 19:06:31 +00:00
test/integration: add upstream 5.10.11 patches
Add patches rebased on top of upstream 5.10.11 tarball. Integration tests for these can be ran as this: make PATCH_DIR="linux-5.10.11" KPATCHBUILD_OPTS="-s /path/to/src/linux-5.10.11" integration-slow Signed-off-by: Artem Savkov <asavkov@redhat.com>
This commit is contained in:
parent
38c2d7315d
commit
0baefa561b
3
test/integration/linux-5.10.11/data-new-LOADED.test
Executable file
3
test/integration/linux-5.10.11/data-new-LOADED.test
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
grep "kpatch: 5" /proc/meminfo
|
20
test/integration/linux-5.10.11/data-new.patch
Normal file
20
test/integration/linux-5.10.11/data-new.patch
Normal file
@ -0,0 +1,20 @@
|
||||
diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c
|
||||
--- src.orig/fs/proc/meminfo.c 2021-01-28 04:47:10.916473090 -0500
|
||||
+++ src/fs/proc/meminfo.c 2021-01-28 04:47:11.459467821 -0500
|
||||
@@ -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;
|
||||
@@ -139,6 +141,7 @@ static int meminfo_proc_show(struct seq_
|
||||
show_val_kb(m, "FilePmdMapped: ",
|
||||
global_node_page_state(NR_FILE_PMDMAPPED) * HPAGE_PMD_NR);
|
||||
#endif
|
||||
+ seq_printf(m, "kpatch: %d\n", foo);
|
||||
|
||||
#ifdef CONFIG_CMA
|
||||
show_val_kb(m, "CmaTotal: ", totalcma_pages);
|
22
test/integration/linux-5.10.11/gcc-static-local-var-6.patch
Normal file
22
test/integration/linux-5.10.11/gcc-static-local-var-6.patch
Normal file
@ -0,0 +1,22 @@
|
||||
diff -Nupr linux-5.10.11.bak/net/ipv6/netfilter.c linux-5.10.11/net/ipv6/netfilter.c
|
||||
--- linux-5.10.11.bak/net/ipv6/netfilter.c 2021-01-28 08:18:59.575109041 -0500
|
||||
+++ linux-5.10.11/net/ipv6/netfilter.c 2021-01-28 08:20:52.399053360 -0500
|
||||
@@ -89,6 +89,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)
|
||||
{
|
||||
@@ -102,6 +104,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)
|
163
test/integration/linux-5.10.11/macro-callbacks.patch
Normal file
163
test/integration/linux-5.10.11/macro-callbacks.patch
Normal file
@ -0,0 +1,163 @@
|
||||
kpatch/livepatch callback test patch:
|
||||
|
||||
vmlinux
|
||||
pcspkr (mod)
|
||||
joydev (mod)
|
||||
|
||||
Note: update joydev's pre-patch callback to return -ENODEV to test failure path
|
||||
|
||||
diff -Nupr src.orig/drivers/input/joydev.c src/drivers/input/joydev.c
|
||||
--- src.orig/drivers/input/joydev.c 2021-01-28 04:45:56.883192829 -0500
|
||||
+++ src/drivers/input/joydev.c 2021-01-28 04:51:13.998114373 -0500
|
||||
@@ -1084,3 +1084,47 @@ static void __exit joydev_exit(void)
|
||||
|
||||
module_init(joydev_init);
|
||||
module_exit(joydev_exit);
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#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 2021-01-28 04:45:56.892192742 -0500
|
||||
+++ src/drivers/input/misc/pcspkr.c 2021-01-28 04:51:14.086113519 -0500
|
||||
@@ -133,3 +133,46 @@ static struct platform_driver pcspkr_pla
|
||||
};
|
||||
module_platform_driver(pcspkr_platform_driver);
|
||||
|
||||
+#include <linux/module.h>
|
||||
+#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 2021-01-28 04:47:10.885473391 -0500
|
||||
+++ src/fs/aio.c 2021-01-28 04:51:14.115113237 -0500
|
||||
@@ -51,6 +51,50 @@
|
||||
|
||||
#define KIOCB_KEY 0
|
||||
|
||||
+#include <linux/module.h>
|
||||
+#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
|
33
test/integration/linux-5.10.11/module-call-external.patch
Normal file
33
test/integration/linux-5.10.11/module-call-external.patch
Normal file
@ -0,0 +1,33 @@
|
||||
diff -Nupr src.orig/fs/nfsd/export.c src/fs/nfsd/export.c
|
||||
--- src.orig/fs/nfsd/export.c 2021-01-28 04:47:10.905473196 -0500
|
||||
+++ src/fs/nfsd/export.c 2021-01-28 04:55:55.117394790 -0500
|
||||
@@ -1234,6 +1234,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;
|
||||
@@ -1243,6 +1245,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 2021-01-28 04:45:47.818280959 -0500
|
||||
+++ src/net/netlink/af_netlink.c 2021-01-28 04:55:55.134394639 -0500
|
||||
@@ -2898,4 +2898,9 @@ panic:
|
||||
panic("netlink_init: Cannot allocate nl_table\n");
|
||||
}
|
||||
|
||||
+char *kpatch_string(void)
|
||||
+{
|
||||
+ return "# kpatch\n";
|
||||
+}
|
||||
+
|
||||
core_initcall(netlink_proto_init);
|
7
test/integration/linux-5.10.11/multiple.test
Executable file
7
test/integration/linux-5.10.11/multiple.test
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))"
|
||||
|
||||
declare -a blacklist=(meminfo-cmdline-rebuild-SLOW-LOADED.test)
|
||||
|
||||
source ${SCRIPTDIR}/../common/multiple.template
|
25
test/integration/linux-5.10.11/new-function.patch
Normal file
25
test/integration/linux-5.10.11/new-function.patch
Normal file
@ -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 2021-01-28 04:45:56.804193597 -0500
|
||||
+++ src/drivers/tty/n_tty.c 2021-01-28 04:59:56.004262703 -0500
|
||||
@@ -2295,7 +2295,7 @@ static ssize_t n_tty_read(struct tty_str
|
||||
* 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;
|
||||
@@ -2382,6 +2382,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
|
34
test/integration/linux-5.10.11/new-globals.patch
Normal file
34
test/integration/linux-5.10.11/new-globals.patch
Normal file
@ -0,0 +1,34 @@
|
||||
diff -Nupr src.orig/fs/proc/cmdline.c src/fs/proc/cmdline.c
|
||||
--- src.orig/fs/proc/cmdline.c 2021-01-28 04:47:10.915473099 -0500
|
||||
+++ src/fs/proc/cmdline.c 2021-01-28 05:04:23.106898578 -0500
|
||||
@@ -17,3 +17,10 @@ static int __init proc_cmdline_init(void
|
||||
return 0;
|
||||
}
|
||||
fs_initcall(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 2021-01-28 04:47:10.916473090 -0500
|
||||
+++ src/fs/proc/meminfo.c 2021-01-28 05:04:23.141898268 -0500
|
||||
@@ -19,6 +19,8 @@
|
||||
#include <asm/page.h>
|
||||
#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);
|
9
test/integration/linux-5.10.11/warn-detect-FAIL.patch
Normal file
9
test/integration/linux-5.10.11/warn-detect-FAIL.patch
Normal file
@ -0,0 +1,9 @@
|
||||
diff -Nupr linux-5.10.11.bak/net/core/dev.c linux-5.10.11/net/core/dev.c
|
||||
--- linux-5.10.11.bak/net/core/dev.c 2021-01-28 08:18:59.936105663 -0500
|
||||
+++ linux-5.10.11/net/core/dev.c 2021-01-28 08:34:03.120655935 -0500
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+
|
||||
/*
|
||||
* NET3 Protocol independent device support routines.
|
||||
*
|
Loading…
Reference in New Issue
Block a user