Merge pull request #838 from jpoimboe/test-cleanups

Test cleanups
This commit is contained in:
Joe Lawrence 2018-04-23 17:31:35 -04:00 committed by GitHub
commit 70959ce6ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
67 changed files with 122 additions and 590 deletions

View File

@ -428,7 +428,7 @@ out:
* 1) immediate move of the line number to %esi * 1) immediate move of the line number to %esi
* 2) (optional) string section rela * 2) (optional) string section rela
* 3) (optional) __warned.xxxxx static local rela * 3) (optional) __warned.xxxxx static local rela
* 4) warn_slowpath_* or __might_sleep or ___might_sleep rela * 4) warn_slowpath_* or __might_sleep or some other similar rela
*/ */
static int kpatch_line_macro_change_only(struct section *sec) static int kpatch_line_macro_change_only(struct section *sec)
{ {
@ -466,15 +466,16 @@ static int kpatch_line_macro_change_only(struct section *sec)
length)) length))
continue; continue;
/* verify it's a mov immediate to %esi */ /* verify it's a mov immediate to %edx or %esi */
insn_get_opcode(&insn1); insn_get_opcode(&insn1);
insn_get_opcode(&insn2); insn_get_opcode(&insn2);
if (insn1.opcode.value != 0xbe || insn2.opcode.value != 0xbe) if (!(insn1.opcode.value == 0xba && insn2.opcode.value == 0xba) &&
!(insn1.opcode.value == 0xbe && insn2.opcode.value == 0xbe))
return 0; return 0;
/* /*
* Verify zero or more string relas followed by a * Verify zero or more string relas followed by a
* warn_slowpath_* or __might_sleep or ___might_sleep rela. * warn_slowpath_* or another similar rela.
*/ */
found = 0; found = 0;
list_for_each_entry(rela, &sec->rela->relas, list) { list_for_each_entry(rela, &sec->rela->relas, list) {
@ -485,8 +486,12 @@ static int kpatch_line_macro_change_only(struct section *sec)
if (!strncmp(rela->sym->name, "__warned.", 9)) if (!strncmp(rela->sym->name, "__warned.", 9))
continue; continue;
if (!strncmp(rela->sym->name, "warn_slowpath_", 14) || if (!strncmp(rela->sym->name, "warn_slowpath_", 14) ||
(!strcmp(rela->sym->name, "__warn_printk")) ||
(!strcmp(rela->sym->name, "__might_sleep")) || (!strcmp(rela->sym->name, "__might_sleep")) ||
(!strcmp(rela->sym->name, "___might_sleep"))) { (!strcmp(rela->sym->name, "___might_sleep")) ||
(!strcmp(rela->sym->name, "__might_fault")) ||
(!strcmp(rela->sym->name, "printk")) ||
(!strcmp(rela->sym->name, "lockdep_rcu_suspicious"))) {
found = 1; found = 1;
break; break;
} }

View File

@ -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 2017-11-17 15:58:41.115211972 -0500
+++ src/fs/proc/proc_sysctl.c 2017-11-17 15:58:51.725211972 -0500
@@ -332,6 +332,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))

View File

@ -1,3 +0,0 @@
#!/bin/bash
grep kpatch=1 /proc/cmdline

View File

@ -1,12 +0,0 @@
diff -Nupr src.orig/fs/proc/cmdline.c src/fs/proc/cmdline.c
--- src.orig/fs/proc/cmdline.c 2017-11-17 15:58:41.126211972 -0500
+++ src/fs/proc/cmdline.c 2017-11-17 15:58:54.891211972 -0500
@@ -5,7 +5,7 @@
static int cmdline_proc_show(struct seq_file *m, void *v)
{
- seq_printf(m, "%s\n", saved_command_line);
+ seq_printf(m, "%s kpatch=1\n", saved_command_line);
return 0;
}

View File

@ -1,11 +0,0 @@
diff -Nupr src.orig/net/core/dev.c src/net/core/dev.c
--- src.orig/net/core/dev.c 2017-11-17 15:58:50.569211972 -0500
+++ src/net/core/dev.c 2017-11-17 15:59:00.286211972 -0500
@@ -4260,6 +4260,7 @@ skip_classify:
case RX_HANDLER_PASS:
break;
default:
+ printk("BUG!\n");
BUG();
}
}

View File

@ -1,12 +0,0 @@
diff -Nupr src.orig/fs/readdir.c src/fs/readdir.c
--- src.orig/fs/readdir.c 2017-11-17 15:58:39.457211972 -0500
+++ src/fs/readdir.c 2017-11-17 15:59:02.078211972 -0500
@@ -189,6 +189,8 @@ static int filldir(struct dir_context *c
goto efault;
}
dirent = buf->current_dir;
+ if (dirent->d_ino == 12345678)
+ printk("kpatch-test: testing .fixup section changes\n");
if (__put_user(d_ino, &dirent->d_ino))
goto efault;
if (__put_user(reclen, &dirent->d_reclen))

View File

@ -1,16 +0,0 @@
ensure timekeeping_forward_now.constprop.8 and
timekeeping_forward_now.constprop.9 are correlated.
diff -Nupr src.orig/kernel/time/timekeeping.c src/kernel/time/timekeeping.c
--- src.orig/kernel/time/timekeeping.c 2017-11-17 15:58:51.500211972 -0500
+++ src/kernel/time/timekeeping.c 2017-11-17 15:59:03.810211972 -0500
@@ -1206,6 +1206,9 @@ void do_gettimeofday(struct timeval *tv)
{
struct timespec64 now;
+ if (!tv)
+ return;
+
getnstimeofday64(&now);
tv->tv_sec = now.tv_sec;
tv->tv_usec = now.tv_nsec/1000;

View File

@ -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 2017-11-17 15:58:41.115211972 -0500
+++ src/fs/proc/proc_sysctl.c 2017-11-17 15:59:05.548211972 -0500
@@ -47,6 +47,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);
}

View File

@ -1,16 +0,0 @@
ensure that __cmpxchg_double_slab.isra.45 and
__cmpxchg_double_slab.isra.45.part.46 aren't correlated.
diff -Nupr src.orig/mm/slub.c src/mm/slub.c
--- src.orig/mm/slub.c 2017-11-17 15:58:51.157211972 -0500
+++ src/mm/slub.c 2017-11-17 15:59:07.361211972 -0500
@@ -5824,6 +5824,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);

View File

@ -1,13 +0,0 @@
diff -Nupr src.orig/mm/mmap.c src/mm/mmap.c
--- src.orig/mm/mmap.c 2017-11-17 15:58:51.131211972 -0500
+++ src/mm/mmap.c 2017-11-17 15:59:09.094211972 -0500
@@ -1609,6 +1610,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;

View File

@ -1,19 +0,0 @@
diff -Nupr src.orig/kernel/reboot.c src/kernel/reboot.c
--- src.orig/kernel/reboot.c 2017-11-17 15:58:51.558211972 -0500
+++ src/kernel/reboot.c 2017-11-17 15:59:10.774211972 -0500
@@ -366,8 +366,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);
}

View File

@ -1,21 +0,0 @@
diff -Nupr src.orig/fs/aio.c src/fs/aio.c
--- src.orig/fs/aio.c 2017-11-17 15:58:38.111211972 -0500
+++ src/fs/aio.c 2017-11-17 15:59:12.467211972 -0500
@@ -271,10 +271,17 @@ 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);

View File

@ -1,7 +0,0 @@
#!/bin/bash
if $(nm kpatch-gcc-static-local-var-4.ko | grep -q free_ioctx); then
exit 1
else
exit 0
fi

View File

@ -1,45 +0,0 @@
diff -Nupr src.orig/kernel/audit.c src/kernel/audit.c
--- src.orig/kernel/audit.c 2017-11-17 15:58:51.516211972 -0500
+++ src/kernel/audit.c 2017-11-17 15:59:14.324211972 -0500
@@ -282,6 +282,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;
@@ -292,6 +298,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);
@@ -311,6 +318,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
@@ -357,6 +369,8 @@ static int audit_log_config_change(char
struct audit_buffer *ab;
int rc = 0;
+ kpatch_audit_check();
+
ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE);
if (unlikely(!ab))
return rc;

View File

@ -1,25 +0,0 @@
diff -Nupr src.orig/arch/x86/kernel/ldt.c src/arch/x86/kernel/ldt.c
--- src.orig/arch/x86/kernel/ldt.c 2017-11-17 15:58:09.662211972 -0500
+++ src/arch/x86/kernel/ldt.c 2017-11-17 15:59:16.084211972 -0500
@@ -100,6 +100,12 @@ static void free_ldt_struct(struct ldt_s
kfree(ldt);
}
+void hi_there(void)
+{
+ if (!jiffies)
+ printk("hi there\n");
+}
+
/*
* we do not have to muck with descriptors here, that is
* done in switch_mm() as needed.
@@ -110,6 +116,8 @@ int init_new_context_ldt(struct task_str
struct mm_struct *old_mm;
int retval = 0;
+ hi_there();
+
mutex_init(&mm->context.lock);
old_mm = current->mm;
if (!old_mm) {

View File

@ -1,147 +0,0 @@
diff -Nupr src.orig/net/ipv4/fib_frontend.c src/net/ipv4/fib_frontend.c
--- src.orig/net/ipv4/fib_frontend.c 2017-11-17 16:16:54.789211972 -0500
+++ src/net/ipv4/fib_frontend.c 2017-11-17 16:19:58.429211972 -0500
@@ -740,6 +740,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)
{
@@ -759,6 +760,7 @@ static int inet_rtm_newroute(struct sk_b
}
err = fib_table_insert(net, tb, &cfg, extack);
+ KPATCH_PRINTK("[inet_rtm_newroute]: err is %d\n", err);
errout:
return err;
}
diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
--- src.orig/net/ipv4/fib_semantics.c 2017-11-17 16:16:54.789211972 -0500
+++ src/net/ipv4/fib_semantics.c 2017-11-17 16:21:11.653211972 -0500
@@ -1026,6 +1026,7 @@ fib_convert_metrics(struct fib_info *fi,
return 0;
}
+#include "kpatch-macros.h"
struct fib_info *fib_create_info(struct fib_config *cfg,
struct netlink_ext_ack *extack)
{
@@ -1059,6 +1060,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;
@@ -1079,6 +1081,7 @@ struct fib_info *fib_create_info(struct
if (!fib_info_hash_size)
goto failure;
}
+ KPATCH_PRINTK("[fib_create_info]: 2 create error err is %d\n",err);
fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
if (!fi)
@@ -1093,6 +1096,8 @@ struct fib_info *fib_create_info(struct
} else {
fi->fib_metrics = (struct dst_metrics *)&dst_default_metrics;
}
+ KPATCH_PRINTK("[fib_create_info]: 3 create error err is %d\n",err);
+
fib_info_cnt++;
fi->fib_net = net;
fi->fib_protocol = cfg->fc_protocol;
@@ -1110,6 +1115,7 @@ struct fib_info *fib_create_info(struct
if (!nexthop_nh->nh_pcpu_rth_output)
goto failure;
} endfor_nexthops(fi)
+ KPATCH_PRINTK("[fib_create_info]: 4 create error err is %d\n",err);
err = fib_convert_metrics(fi, cfg);
if (err)
@@ -1174,6 +1180,9 @@ struct fib_info *fib_create_info(struct
#endif
}
+ KPATCH_PRINTK("[fib_create_info]: 5 create error err is %d\n",err);
+ KPATCH_PRINTK("[fib_create_info]: 6 create error err is %d\n",err);
+
if (fib_props[cfg->fc_type].error) {
if (cfg->fc_gw || cfg->fc_oif || cfg->fc_mp) {
NL_SET_ERR_MSG(extack,
@@ -1194,6 +1203,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");
@@ -1232,6 +1242,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");
@@ -1242,6 +1253,7 @@ struct fib_info *fib_create_info(struct
fib_info_update_nh_saddr(net, nexthop_nh);
fib_add_weight(fi, nexthop_nh);
} endfor_nexthops(fi)
+ KPATCH_PRINTK("[fib_create_info]: 9 create error err is %d\n",err);
fib_rebalance(fi);
@@ -1253,6 +1265,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);
@@ -1276,6 +1289,7 @@ link_it:
hlist_add_head(&nexthop_nh->nh_hash, head);
} endfor_nexthops(fi)
spin_unlock_bh(&fib_info_lock);
+ KPATCH_PRINTK("[fib_create_info]: 11 create error err is %d\n",err);
return fi;
err_inval:
@@ -1286,6 +1300,7 @@ failure:
fi->fib_dead = 1;
free_fib_info(fi);
}
+ KPATCH_PRINTK("[fib_create_info]: 12 create error err is %d\n",err);
return ERR_PTR(err);
}
diff -Nupr src.orig/net/ipv4/fib_trie.c src/net/ipv4/fib_trie.c
--- src.orig/net/ipv4/fib_trie.c 2017-11-17 16:16:54.789211972 -0500
+++ src/net/ipv4/fib_trie.c 2017-11-17 16:22:11.702211972 -0500
@@ -1116,6 +1116,7 @@ static bool fib_valid_key_len(u32 key, u
}
/* 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)
{
@@ -1138,11 +1139,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,

View File

@ -1,11 +0,0 @@
diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c
--- src.orig/fs/proc/meminfo.c 2017-11-17 15:58:41.113211972 -0500
+++ src/fs/proc/meminfo.c 2017-11-17 15:59:23.081211972 -0500
@@ -175,6 +175,7 @@ static const struct file_operations memi
static int __init proc_meminfo_init(void)
{
+ printk("a\n");
proc_create("meminfo", 0, NULL, &meminfo_proc_fops);
return 0;
}

View File

@ -1,20 +0,0 @@
diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c
--- src.orig/fs/proc/meminfo.c 2017-11-17 15:58:41.113211972 -0500
+++ src/fs/proc/meminfo.c 2017-11-17 15:59:21.276211972 -0500
@@ -51,6 +51,8 @@ static int meminfo_proc_show(struct seq_
unsigned long pages[NR_LRU_LISTS];
int lru;
+ printk("a\n");
+
si_meminfo(&i);
si_swapinfo(&i);
committed = percpu_counter_read_positive(&vm_committed_as);
@@ -175,6 +177,7 @@ static const struct file_operations memi
static int __init proc_meminfo_init(void)
{
+ printk("a\n");
proc_create("meminfo", 0, NULL, &meminfo_proc_fops);
return 0;
}

View File

@ -1,3 +0,0 @@
#!/bin/bash
grep VMALLOCCHUNK /proc/meminfo

View File

@ -1,12 +0,0 @@
diff -Nupr src.orig/fs/proc/meminfo.c src/fs/proc/meminfo.c
--- src.orig/fs/proc/meminfo.c 2017-11-17 15:59:24.724211972 -0500
+++ src/fs/proc/meminfo.c 2017-11-17 15:59:24.721211972 -0500
@@ -132,7 +132,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: ", 0ul);
- show_val_kb(m, "VmallocChunk: ", 0ul);
+ show_val_kb(m, "VMALLOCCHUNK: ", 0ul);
#ifdef CONFIG_MEMORY_FAILURE
seq_printf(m, "HardwareCorrupted: %5lu kB\n",

View File

@ -1,12 +0,0 @@
diff -Nupr src.orig/arch/x86/kvm/vmx.c src/arch/x86/kvm/vmx.c
--- src.orig/arch/x86/kvm/vmx.c 2017-11-17 15:58:19.369211972 -0500
+++ src/arch/x86/kvm/vmx.c 2017-11-17 15:59:27.980211972 -0500
@@ -11275,6 +11275,8 @@ static int vmx_check_intercept(struct kv
struct x86_instruction_info *info,
enum x86_intercept_stage stage)
{
+ if (!jiffies)
+ printk("kpatch vmx_check_intercept\n");
return X86EMUL_CONTINUE;
}

View File

@ -1,11 +0,0 @@
diff -Nupr src.orig/fs/proc/generic.c src/fs/proc/generic.c
--- src.orig/fs/proc/generic.c 2017-11-17 16:08:17.202211972 -0500
+++ src/fs/proc/generic.c 2017-11-17 16:08:46.585211972 -0500
@@ -191,6 +191,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)

View File

@ -1,12 +0,0 @@
diff -Nupr src.orig/arch/x86/kvm/x86.c src/arch/x86/kvm/x86.c
--- src.orig/arch/x86/kvm/x86.c 2017-11-17 15:58:19.002211972 -0500
+++ src/arch/x86/kvm/x86.c 2017-11-17 15:59:34.499211972 -0500
@@ -252,6 +252,8 @@ static void shared_msr_update(unsigned s
void kvm_define_shared_msr(unsigned slot, u32 msr)
{
+ if (!jiffies)
+ printk("kpatch kvm define shared msr\n");
BUG_ON(slot >= KVM_NR_SHARED_MSRS);
shared_msrs_global.msrs[slot] = msr;
if (slot >= shared_msrs_global.nr)

View File

@ -1,12 +0,0 @@
diff -Nupr src.orig/drivers/tty/tty_buffer.c src/drivers/tty/tty_buffer.c
--- src.orig/drivers/tty/tty_buffer.c 2017-11-17 15:58:00.518211972 -0500
+++ src/drivers/tty/tty_buffer.c 2017-11-17 15:59:37.806211972 -0500
@@ -255,6 +255,8 @@ 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;

View File

@ -1,24 +0,0 @@
diff -Nupr src.orig/arch/x86/kvm/x86.c src/arch/x86/kvm/x86.c
--- src.orig/arch/x86/kvm/x86.c 2017-11-17 15:58:19.002211972 -0500
+++ src/arch/x86/kvm/x86.c 2017-11-17 15:59:39.427211972 -0500
@@ -2126,12 +2126,20 @@ static void record_steal_time(struct kvm
&vcpu->arch.st.steal, sizeof(struct kvm_steal_time));
}
+void kpatch_kvm_x86_foo(void)
+{
+ if (!jiffies)
+ printk("kpatch kvm x86 foo\n");
+}
+
int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
{
bool pr = false;
u32 msr = msr_info->index;
u64 data = msr_info->data;
+ kpatch_kvm_x86_foo();
+
switch (msr) {
case MSR_AMD64_NB_CFG:
case MSR_IA32_UCODE_REV:

View File

@ -1,22 +0,0 @@
diff -Nupr src.orig/kernel/fork.c src/kernel/fork.c
--- src.orig/kernel/fork.c 2017-11-17 15:58:51.541211972 -0500
+++ src/kernel/fork.c 2017-11-17 15:59:41.041211972 -0500
@@ -1374,10 +1374,18 @@ static void posix_cpu_timers_init_group(
static inline void posix_cpu_timers_init_group(struct signal_struct *sig) { }
#endif
+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;

View File

@ -1,15 +0,0 @@
ensure __jump_table is parsed and we can tell that it effectively didn't change
diff -Nupr src.orig/kernel/time/timer.c src/kernel/time/timer.c
--- src.orig/kernel/time/timer.c 2017-11-17 15:58:51.501211972 -0500
+++ src/kernel/time/timer.c 2017-11-17 15:59:42.654211972 -0500
@@ -1643,6 +1643,9 @@ static __latent_entropy void run_timer_s
*/
base->must_forward_clk = false;
+ if (!base)
+ printk("kpatch-test: testing __tracepoints section changes\n");
+
__run_timers(base);
if (IS_ENABLED(CONFIG_NO_HZ_COMMON) && base->nohz_active)
__run_timers(this_cpu_ptr(&timer_bases[BASE_DEF]));

View File

@ -1,8 +1,9 @@
diff -Nupr src.orig/arch/x86/kvm/x86.c src/arch/x86/kvm/x86.c diff --git a/net/core/dev.c b/net/core/dev.c
--- src.orig/arch/x86/kvm/x86.c 2017-11-17 15:58:19.002211972 -0500 index ef0cc6ea5f8d..9a840ec54270 100644
+++ src/arch/x86/kvm/x86.c 2017-11-17 15:59:44.327211972 -0500 --- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
+ +
/* /*
* Kernel-based Virtual Machine driver for Linux * NET3 Protocol independent device support routines.
* *

12
test/test-functions.sh Normal file
View File

@ -0,0 +1,12 @@
FILE=$1
assert_num_funcs() {
local num_funcs=$(nm $FILE | grep -i " t " | wc -l)
if [[ $num_funcs != $1 ]]; then
echo "$FILE: assertion failed: file has $num_funcs funcs, expected $1" 1>&2
exit 1
fi
return 0
}

View File

@ -9,12 +9,15 @@ TNAME = $(@:.$(EXT_OUTPUT)=)
ifndef VERBOSE ifndef VERBOSE
MUTE_PASS := >/dev/null MUTE_PASS := >/dev/null
MUTE_FAIL := >/dev/null 2>&1 MUTE_FAIL := >/dev/null 2>&1
.SILENT: $(TARGETS) $(TEST_TARGETS)
endif endif
SRC_PATH ?= $(realpath ../../../) SRC_PATH ?= $(realpath ../../../)
CDO ?= $(SRC_PATH)/kpatch-build/create-diff-object CDO ?= $(SRC_PATH)/kpatch-build/create-diff-object
TEST_LIBRARY ?= $(SRC_PATH)/test/test-functions.sh
TENV = PARA_STRUCT_SIZE=16 EX_STRUCT_SIZE=12 BUG_STRUCT_SIZE=12 ALT_STRUCT_SIZE=13 CDO_ENV = PARA_STRUCT_SIZE=16 EX_STRUCT_SIZE=12 BUG_STRUCT_SIZE=12 ALT_STRUCT_SIZE=13
TEST_ENV = KPATCH_TEST_LIBRARY=$(TEST_LIBRARY)
TARGETS = $(patsubst %.$(EXT_ORIG),%.$(EXT_OUTPUT),$(wildcard *.$(EXT_ORIG))) TARGETS = $(patsubst %.$(EXT_ORIG),%.$(EXT_OUTPUT),$(wildcard *.$(EXT_ORIG)))
TEST_TARGETS = $(patsubst %.$(EXT_TEST),%.$(EXT_TEST_OUTPUT),$(wildcard *.$(EXT_TEST))) TEST_TARGETS = $(patsubst %.$(EXT_TEST),%.$(EXT_TEST_OUTPUT),$(wildcard *.$(EXT_TEST)))
@ -39,23 +42,26 @@ endef
all: $(TARGETS) $(TEST_TARGETS) all: $(TARGETS) $(TEST_TARGETS)
clean: clean:
rm -f $(TARGETS) $(TEST_TARGETS) rm -f *.$(EXT_TEST_OUTPUT) *.$(EXT_OUTPUT)
%.$(EXT_TEST_OUTPUT): %.$(EXT_OUTPUT) %.$(EXT_TEST) %.$(EXT_TEST_OUTPUT): %.$(EXT_OUTPUT) %.$(EXT_TEST) $(TEST_LIBRARY)
bash $(@:.$(EXT_TEST_OUTPUT)=.$(EXT_TEST)) $< @echo "TEST $(@:.$(EXT_TEST_OUTPUT)=)"
$(TEST_ENV) bash $(@:.$(EXT_TEST_OUTPUT)=.$(EXT_TEST)) $<
# Don't rely on script creating this # Don't rely on script creating this
@touch $@ @touch $@
%.$(EXT_OUTPUT): %.$(EXT_ORIG) %.$(EXT_PATCHED) $(CDO) %.$(EXT_OUTPUT): %.$(EXT_ORIG) %.$(EXT_PATCHED) $(CDO)
@echo "BUILD $(TNAME)"
$(call check_all,$(TNAME).$(EXT_ORIG)) $(call check_all,$(TNAME).$(EXT_ORIG))
$(call check_all,$(TNAME).$(EXT_PATCHED)) $(call check_all,$(TNAME).$(EXT_PATCHED))
$(TENV) $(CDO) $(TNAME).$(EXT_ORIG) $(TNAME).$(EXT_PATCHED) \ $(CDO_ENV) $(CDO) $(TNAME).$(EXT_ORIG) $(TNAME).$(EXT_PATCHED) \
$(TNAME).$(EXT_ORIG) $@ /dev/null test_$(TNAME) $(MUTE_PASS) $(TNAME).$(EXT_ORIG) $@ /dev/null test_$(TNAME) $(MUTE_PASS)
%.$(EXT_OUTPUT): %.$(EXT_ORIG) %.$(EXT_FAIL) $(CDO) %.$(EXT_OUTPUT): %.$(EXT_ORIG) %.$(EXT_FAIL) $(CDO)
@echo "BUILD $(TNAME)-FAIL"
$(call check_all,$(TNAME).$(EXT_ORIG)) $(call check_all,$(TNAME).$(EXT_ORIG))
$(call check_all,$(TNAME).$(EXT_FAIL)) $(call check_all,$(TNAME).$(EXT_FAIL))
! $(TENV) $(CDO) $(TNAME).$(EXT_ORIG) $(TNAME).$(EXT_FAIL) \ ! $(CDO_ENV) $(CDO) $(TNAME).$(EXT_ORIG) $(TNAME).$(EXT_FAIL) \
$(TNAME).$(EXT_ORIG) $@ /dev/null test_$(TNAME) $(MUTE_FAIL) $(TNAME).$(EXT_ORIG) $@ /dev/null test_$(TNAME) $(MUTE_FAIL)
# Expecting to fail, thus create output file manually so we won't rerun the # Expecting to fail, thus create output file manually so we won't rerun the
# test without clean # test without clean

View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 1

View File

@ -0,0 +1,9 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 1
bind=$(nm $1 |awk '/__kmalloc/ {print $2}')
[[ $bind = 't' ]] || exit 1
exit 0

4
test/unit/x86_64/data-new.test Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 1

View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 1

View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 1

View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 2

View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 1

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4a5d756499e91c19b712ca0534c3469bb0576941ae649f51d21505643719b8f2
size 45272

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:607339c8d247162e67a8770892ec5e0a77d9a743fa6c2a623ed92b24044a3235
size 45512

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3c49c9fdd4df5bac01c1abe0947c404393a4e9d6654f2c883e0413f9d54b3962
size 157736

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3de719e0324331e64ab1230b0c3a844701162519844a3a689da186deb6f19f8f
size 157984

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5705ea1d1917fa1829f7a70979bfae3fcf17635e3b1c76f3358dda57673f28e1
size 68728

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:21027abe867833593505f69a381d06519647c6e52551a1b67522a6600561d31b
size 69008

View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 2

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d165518f5f75ea16f4edb63fabca532aa98571bbc9e151cfdafb2575f352acb1
size 69560

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9a07e8acf553af1c7b001fd37e3acb3d21a6eff87fe0b75f5a5d425a72802253
size 70256

View File

@ -1,7 +0,0 @@
#!/bin/bash
if $(nm ${1} | grep -q free_ioctx); then
exit 1
else
exit 0
fi

View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 5

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d165518f5f75ea16f4edb63fabca532aa98571bbc9e151cfdafb2575f352acb1
size 69560

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a41f8dcd6ed3eddfed5a9d1be3776936fff13d9fc276d39e66d6daede1be8868
size 70984

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:550e34f0e1ad732f6fb2adee2b8ef40c23959770f3885a99b03387df1ca8b479
size 9696

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2db6c477940a25d879a91b92d2913f7f268602187d81be551d7623e3caed0f49
size 9696

View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 1

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9e928bc0240f0d844d5bc5b83faa7e39359db85bdeb050d07031fc87646c458d
size 380192

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:192874c24acee410915a76883571accffff03636fc7232313caa901d9b8b13f2
size 380512

View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 2

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:772b7f5b3c6f0459d4f6410255daa2840b2889375ae62138fd196317a015c430
size 26280

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dec5ecd177b53d044742bd0e99b3fc09f649ff0f290b5928601c58e5aea37ffd
size 26440

View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 1

View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 1

View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 2

View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 2

View File

@ -0,0 +1,4 @@
#!/bin/bash
source $KPATCH_TEST_LIBRARY
assert_num_funcs 1

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3e3dd874c11ffe5f92fbaf3cd4975e93b991896963a329b12d45828a45a63f50
size 267648

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:152b15d618ed8c2ae3476bf179147a02501920b948e81ad15d6e8e124d456933
size 267648