mirror of
https://github.com/dynup/kpatch
synced 2025-02-19 19:26:53 +00:00
Merge pull request #932 from sm00th/integration-cleanup
integration tests cleanup
This commit is contained in:
commit
9999608062
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
if $(nm kpatch-gcc-static-local-var-4.ko | grep -q free_ioctx); then
|
||||
if $(nm test-gcc-static-local-var-4.ko | grep -q free_ioctx); then
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
|
@ -1,7 +1,8 @@
|
||||
diff -Nupr src.orig/net/ipv4/fib_frontend.c src/net/ipv4/fib_frontend.c
|
||||
--- src.orig/net/ipv4/fib_frontend.c 2017-09-22 16:52:10.646110299 -0400
|
||||
+++ src/net/ipv4/fib_frontend.c 2017-09-22 16:55:14.395870305 -0400
|
||||
@@ -633,6 +633,7 @@ errout:
|
||||
Index: src/net/ipv4/fib_frontend.c
|
||||
===================================================================
|
||||
--- src.orig/net/ipv4/fib_frontend.c
|
||||
+++ src/net/ipv4/fib_frontend.c
|
||||
@@ -685,6 +685,7 @@ errout:
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -9,7 +10,7 @@ diff -Nupr src.orig/net/ipv4/fib_frontend.c src/net/ipv4/fib_frontend.c
|
||||
static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh)
|
||||
{
|
||||
struct net *net = sock_net(skb->sk);
|
||||
@@ -651,6 +652,7 @@ static int inet_rtm_newroute(struct sk_b
|
||||
@@ -703,6 +704,7 @@ static int inet_rtm_newroute(struct sk_b
|
||||
}
|
||||
|
||||
err = fib_table_insert(net, tb, &cfg);
|
||||
@ -17,10 +18,11 @@ diff -Nupr src.orig/net/ipv4/fib_frontend.c src/net/ipv4/fib_frontend.c
|
||||
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-09-22 16:52:10.645110295 -0400
|
||||
+++ src/net/ipv4/fib_semantics.c 2017-09-22 16:54:05.175584004 -0400
|
||||
@@ -925,6 +925,7 @@ fib_convert_metrics(struct fib_info *fi,
|
||||
Index: src/net/ipv4/fib_semantics.c
|
||||
===================================================================
|
||||
--- src.orig/net/ipv4/fib_semantics.c
|
||||
+++ src/net/ipv4/fib_semantics.c
|
||||
@@ -969,6 +969,7 @@ fib_convert_metrics(struct fib_info *fi,
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -28,7 +30,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
struct fib_info *fib_create_info(struct fib_config *cfg)
|
||||
{
|
||||
int err;
|
||||
@@ -949,6 +950,7 @@ struct fib_info *fib_create_info(struct
|
||||
@@ -993,6 +994,7 @@ struct fib_info *fib_create_info(struct
|
||||
#endif
|
||||
|
||||
err = -ENOBUFS;
|
||||
@ -36,7 +38,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
if (fib_info_cnt >= fib_info_hash_size) {
|
||||
unsigned int new_size = fib_info_hash_size << 1;
|
||||
struct hlist_head *new_info_hash;
|
||||
@@ -969,6 +971,7 @@ struct fib_info *fib_create_info(struct
|
||||
@@ -1013,6 +1015,7 @@ struct fib_info *fib_create_info(struct
|
||||
if (!fib_info_hash_size)
|
||||
goto failure;
|
||||
}
|
||||
@ -44,15 +46,15 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
|
||||
if (fi == NULL)
|
||||
@@ -980,6 +983,7 @@ struct fib_info *fib_create_info(struct
|
||||
} else
|
||||
fi->fib_metrics = (u32 *) dst_default_metrics;
|
||||
@@ -1028,6 +1031,7 @@ struct fib_info *fib_create_info(struct
|
||||
fi->fib_metrics = (struct dst_metrics *)&dst_default_metrics;
|
||||
}
|
||||
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;
|
||||
@@ -996,8 +1000,10 @@ struct fib_info *fib_create_info(struct
|
||||
fi->fib_scope = cfg->fc_scope;
|
||||
@@ -1043,8 +1047,10 @@ struct fib_info *fib_create_info(struct
|
||||
if (!nexthop_nh->nh_pcpu_rth_output)
|
||||
goto failure;
|
||||
} endfor_nexthops(fi)
|
||||
@ -63,7 +65,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
if (err)
|
||||
goto failure;
|
||||
|
||||
@@ -1048,6 +1054,7 @@ struct fib_info *fib_create_info(struct
|
||||
@@ -1095,6 +1101,7 @@ struct fib_info *fib_create_info(struct
|
||||
nh->nh_weight = 1;
|
||||
#endif
|
||||
}
|
||||
@ -71,7 +73,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
if (fib_props[cfg->fc_type].error) {
|
||||
if (cfg->fc_gw || cfg->fc_oif || cfg->fc_mp)
|
||||
@@ -1065,6 +1072,7 @@ struct fib_info *fib_create_info(struct
|
||||
@@ -1112,6 +1119,7 @@ struct fib_info *fib_create_info(struct
|
||||
goto err_inval;
|
||||
}
|
||||
}
|
||||
@ -79,7 +81,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
if (cfg->fc_scope > RT_SCOPE_HOST)
|
||||
goto err_inval;
|
||||
@@ -1087,6 +1095,7 @@ struct fib_info *fib_create_info(struct
|
||||
@@ -1134,6 +1142,7 @@ struct fib_info *fib_create_info(struct
|
||||
goto failure;
|
||||
} endfor_nexthops(fi)
|
||||
}
|
||||
@ -87,7 +89,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
if (fi->fib_prefsrc) {
|
||||
if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst ||
|
||||
@@ -1099,6 +1108,7 @@ struct fib_info *fib_create_info(struct
|
||||
@@ -1146,6 +1155,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)
|
||||
@ -95,7 +97,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
fib_rebalance(fi);
|
||||
|
||||
@@ -1110,6 +1120,7 @@ link_it:
|
||||
@@ -1157,6 +1167,7 @@ link_it:
|
||||
ofi->fib_treeref++;
|
||||
return ofi;
|
||||
}
|
||||
@ -103,7 +105,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
fi->fib_treeref++;
|
||||
atomic_inc(&fi->fib_clntref);
|
||||
@@ -1133,6 +1144,7 @@ link_it:
|
||||
@@ -1180,6 +1191,7 @@ link_it:
|
||||
hlist_add_head(&nexthop_nh->nh_hash, head);
|
||||
} endfor_nexthops(fi)
|
||||
spin_unlock_bh(&fib_info_lock);
|
||||
@ -111,7 +113,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
return fi;
|
||||
|
||||
err_inval:
|
||||
@@ -1143,6 +1155,7 @@ failure:
|
||||
@@ -1190,6 +1202,7 @@ failure:
|
||||
fi->fib_dead = 1;
|
||||
free_fib_info(fi);
|
||||
}
|
||||
@ -119,10 +121,11 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
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-09-22 16:52:10.645110295 -0400
|
||||
+++ src/net/ipv4/fib_trie.c 2017-09-22 16:55:39.940975963 -0400
|
||||
@@ -1191,6 +1191,7 @@ static int fib_insert_alias(struct trie
|
||||
Index: src/net/ipv4/fib_trie.c
|
||||
===================================================================
|
||||
--- src.orig/net/ipv4/fib_trie.c
|
||||
+++ src/net/ipv4/fib_trie.c
|
||||
@@ -1105,6 +1105,7 @@ static int fib_insert_alias(struct trie
|
||||
}
|
||||
|
||||
/* Caller must hold RTNL. */
|
||||
@ -130,7 +133,7 @@ diff -Nupr src.orig/net/ipv4/fib_trie.c src/net/ipv4/fib_trie.c
|
||||
int fib_table_insert(struct net *net, struct fib_table *tb,
|
||||
struct fib_config *cfg)
|
||||
{
|
||||
@@ -1216,11 +1217,14 @@ int fib_table_insert(struct net *net, st
|
||||
@@ -1130,11 +1131,14 @@ int fib_table_insert(struct net *net, st
|
||||
if ((plen < KEYLENGTH) && (key << plen))
|
||||
return -EINVAL;
|
||||
|
||||
@ -144,4 +147,4 @@ diff -Nupr src.orig/net/ipv4/fib_trie.c src/net/ipv4/fib_trie.c
|
||||
+ 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) : NULL;
|
||||
fa = l ? fib_find_alias(&l->leaf, slen, tos, fi->fib_priority,
|
||||
|
@ -1,3 +1,5 @@
|
||||
Disabled due to CSWTITCH issue from https://github.com/dynup/kpatch/issues/876
|
||||
---
|
||||
diff -Nupr src.orig/fs/proc/cmdline.c src/fs/proc/cmdline.c
|
||||
--- src.orig/fs/proc/cmdline.c 2017-09-22 15:27:21.698056175 -0400
|
||||
+++ src/fs/proc/cmdline.c 2017-09-22 15:27:37.842123028 -0400
|
@ -1,22 +1,23 @@
|
||||
diff -Nupr src.orig/arch/x86/kvm/vmx.c src/arch/x86/kvm/vmx.c
|
||||
--- src.orig/arch/x86/kvm/vmx.c 2017-09-22 15:27:20.853052676 -0400
|
||||
+++ src/arch/x86/kvm/vmx.c 2017-09-22 15:27:44.742151601 -0400
|
||||
@@ -10581,10 +10581,20 @@ static void vmx_leave_nested(struct kvm_
|
||||
Index: src/arch/x86/kvm/vmx.c
|
||||
===================================================================
|
||||
--- src.orig/arch/x86/kvm/vmx.c
|
||||
+++ src/arch/x86/kvm/vmx.c
|
||||
@@ -11406,10 +11406,20 @@ static void vmx_leave_nested(struct kvm_
|
||||
* It should only be called before L2 actually succeeded to run, and when
|
||||
* vmcs01 is current (it doesn't leave_guest_mode() or switch vmcss).
|
||||
*/
|
||||
+#include "kpatch.h"
|
||||
+#include <linux/livepatch.h>
|
||||
static void nested_vmx_entry_failure(struct kvm_vcpu *vcpu,
|
||||
struct vmcs12 *vmcs12,
|
||||
u32 reason, unsigned long qualification)
|
||||
{
|
||||
+ int *kpatch;
|
||||
+
|
||||
+ kpatch = kpatch_shadow_alloc(vcpu, "kpatch", sizeof(*kpatch),
|
||||
+ GFP_KERNEL);
|
||||
+ kpatch = klp_shadow_alloc(vcpu, 0, sizeof(*kpatch),
|
||||
+ GFP_KERNEL, NULL, NULL);
|
||||
+ if (kpatch) {
|
||||
+ kpatch_shadow_get(vcpu, "kpatch");
|
||||
+ kpatch_shadow_free(vcpu, "kpatch");
|
||||
+ klp_shadow_get(vcpu, 0);
|
||||
+ klp_shadow_free(vcpu, 0, NULL);
|
||||
+ }
|
||||
+
|
||||
load_vmcs12_host_state(vcpu, vmcs12);
|
||||
|
@ -4,6 +4,10 @@ SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))"
|
||||
ROOTDIR="$(readlink -f $SCRIPTDIR/../../..)"
|
||||
KPATCH="sudo $ROOTDIR/kpatch/kpatch"
|
||||
|
||||
MODULE_PREFIX="test-"
|
||||
MODULE_POSTFIX=".ko"
|
||||
TEST_POSTFIX="-LOADED.test"
|
||||
|
||||
set -o errexit
|
||||
|
||||
die() {
|
||||
@ -12,12 +16,27 @@ die() {
|
||||
}
|
||||
|
||||
ko_to_test() {
|
||||
tmp=${1%.ko}-LOADED.test
|
||||
echo ${tmp#kpatch-}
|
||||
tmp=${1%${MODULE_POSTFIX}}${TEST_POSTFIX}
|
||||
echo ${tmp#${MODULE_PREFIX}}
|
||||
}
|
||||
|
||||
# make sure any modules added here are disjoint
|
||||
declare -a modules=(kpatch-cmdline-string.ko kpatch-meminfo-string.ko)
|
||||
declare -a modules
|
||||
declare -a blacklist=(data-new-LOADED.test)
|
||||
|
||||
for file in "${SCRIPTDIR}"/*"${TEST_POSTFIX}"; do
|
||||
name=$(basename ${file})
|
||||
skip=0
|
||||
for bname in "${blacklist[@]}"; do
|
||||
if [ "${bname}" == "${name}" ]; then
|
||||
skip=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ ${skip} -eq 0 ]; then
|
||||
modules+=(${MODULE_PREFIX}${name%${TEST_POSTFIX}}${MODULE_POSTFIX})
|
||||
fi
|
||||
done
|
||||
|
||||
for mod in "${modules[@]}"; do
|
||||
testprog=$(ko_to_test $mod)
|
||||
@ -33,7 +52,8 @@ for mod in "${modules[@]}"; do
|
||||
$SCRIPTDIR/$testprog || die "$SCRIPTDIR/$testprog failed after loading modules"
|
||||
done
|
||||
|
||||
for mod in "${modules[@]}"; do
|
||||
for ((idx=${#modules[@]}-1 ; idx>=0 ; idx--)); do
|
||||
mod=${modules[idx]}
|
||||
$KPATCH unload $mod
|
||||
done
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
diff -Nupr src.orig/fs/proc/array.c src/fs/proc/array.c
|
||||
--- src.orig/fs/proc/array.c 2017-09-22 16:52:10.597110096 -0400
|
||||
+++ src/fs/proc/array.c 2017-09-22 16:59:40.799972178 -0400
|
||||
@@ -359,13 +359,20 @@ static inline void task_seccomp(struct s
|
||||
#endif
|
||||
Index: src/fs/proc/array.c
|
||||
===================================================================
|
||||
--- src.orig/fs/proc/array.c
|
||||
+++ src/fs/proc/array.c
|
||||
@@ -394,13 +394,20 @@ static inline void task_seccomp(struct s
|
||||
seq_putc(m, '\n');
|
||||
}
|
||||
|
||||
+#include "kpatch.h"
|
||||
+#include <linux/livepatch.h>
|
||||
static inline void task_context_switch_counts(struct seq_file *m,
|
||||
struct task_struct *p)
|
||||
{
|
||||
@ -16,52 +17,54 @@ diff -Nupr src.orig/fs/proc/array.c src/fs/proc/array.c
|
||||
p->nvcsw,
|
||||
p->nivcsw);
|
||||
+
|
||||
+ newpid = kpatch_shadow_get(p, "newpid");
|
||||
+ 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 2017-09-22 16:52:10.506109720 -0400
|
||||
+++ src/kernel/exit.c 2017-09-22 16:59:40.799972178 -0400
|
||||
@@ -715,6 +715,7 @@ static void check_stack_usage(void)
|
||||
Index: src/kernel/exit.c
|
||||
===================================================================
|
||||
--- src.orig/kernel/exit.c
|
||||
+++ src/kernel/exit.c
|
||||
@@ -791,6 +791,7 @@ static void check_stack_usage(void)
|
||||
static inline void check_stack_usage(void) {}
|
||||
#endif
|
||||
|
||||
+#include "kpatch.h"
|
||||
+#include <linux/livepatch.h>
|
||||
void do_exit(long code)
|
||||
{
|
||||
struct task_struct *tsk = current;
|
||||
@@ -812,6 +813,8 @@ void do_exit(long code)
|
||||
@@ -888,6 +889,8 @@ void do_exit(long code)
|
||||
check_stack_usage();
|
||||
exit_thread();
|
||||
|
||||
+ kpatch_shadow_free(tsk, "newpid");
|
||||
+ 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 2017-09-22 16:52:10.504109711 -0400
|
||||
+++ src/kernel/fork.c 2017-09-22 17:00:44.938237460 -0400
|
||||
@@ -1700,6 +1700,7 @@ struct task_struct *fork_idle(int cpu)
|
||||
Index: src/kernel/fork.c
|
||||
===================================================================
|
||||
--- src.orig/kernel/fork.c
|
||||
+++ src/kernel/fork.c
|
||||
@@ -1757,6 +1757,7 @@ struct task_struct *fork_idle(int cpu)
|
||||
* It copies the process, and if successful kick-starts
|
||||
* it and waits for it to finish using the VM if required.
|
||||
*/
|
||||
+#include "kpatch.h"
|
||||
+#include <linux/livepatch.h>
|
||||
long do_fork(unsigned long clone_flags,
|
||||
unsigned long stack_start,
|
||||
unsigned long stack_size,
|
||||
@@ -1737,6 +1738,13 @@ long do_fork(unsigned long clone_flags,
|
||||
@@ -1794,6 +1795,13 @@ long do_fork(unsigned long clone_flags,
|
||||
if (!IS_ERR(p)) {
|
||||
struct completion vfork;
|
||||
struct pid *pid;
|
||||
+ int *newpid;
|
||||
+ static int ctr = 0;
|
||||
+
|
||||
+ newpid = kpatch_shadow_alloc(p, "newpid", sizeof(*newpid),
|
||||
+ GFP_KERNEL);
|
||||
+ newpid = klp_shadow_alloc(p, 0, sizeof(*newpid),
|
||||
+ GFP_KERNEL, NULL, NULL);
|
||||
+ if (newpid)
|
||||
+ *newpid = ctr++;
|
||||
|
||||
|
@ -1,35 +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:59:19.323211972 -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;
|
||||
}
|
||||
|
||||
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:19.323211972 -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",
|
||||
diff -Nupr src.orig/include/linux/kernel.h src/include/linux/kernel.h
|
||||
--- src.orig/include/linux/kernel.h 2017-11-17 15:58:48.205211972 -0500
|
||||
+++ src/include/linux/kernel.h 2017-11-17 15:59:19.376211972 -0500
|
||||
@@ -2,6 +2,7 @@
|
||||
#define _LINUX_KERNEL_H
|
||||
|
||||
|
||||
+
|
||||
#include <stdarg.h>
|
||||
#include <linux/linkage.h>
|
||||
#include <linux/stddef.h>
|
@ -0,0 +1,40 @@
|
||||
Disabled due to https://github.com/dynup/kpatch/issues/767
|
||||
---
|
||||
Index: src/fs/proc/cmdline.c
|
||||
===================================================================
|
||||
--- src.orig/fs/proc/cmdline.c
|
||||
+++ src/fs/proc/cmdline.c
|
||||
@@ -7,7 +7,7 @@
|
||||
static int cmdline_proc_show(struct seq_file *m, void *v)
|
||||
{
|
||||
seq_puts(m, saved_command_line);
|
||||
- seq_putc(m, '\n');
|
||||
+ seq_puts(m, " kpatch=1\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Index: src/fs/proc/meminfo.c
|
||||
===================================================================
|
||||
--- src.orig/fs/proc/meminfo.c
|
||||
+++ src/fs/proc/meminfo.c
|
||||
@@ -120,7 +120,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",
|
||||
Index: src/include/linux/kernel.h
|
||||
===================================================================
|
||||
--- src.orig/include/linux/kernel.h
|
||||
+++ src/include/linux/kernel.h
|
||||
@@ -3,6 +3,7 @@
|
||||
#define _LINUX_KERNEL_H
|
||||
|
||||
|
||||
+
|
||||
#include <stdarg.h>
|
||||
#include <linux/linkage.h>
|
||||
#include <linux/stddef.h>
|
@ -4,6 +4,10 @@ SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))"
|
||||
ROOTDIR="$(readlink -f $SCRIPTDIR/../../..)"
|
||||
KPATCH="sudo $ROOTDIR/kpatch/kpatch"
|
||||
|
||||
MODULE_PREFIX="test-"
|
||||
MODULE_POSTFIX=".ko"
|
||||
TEST_POSTFIX="-LOADED.test"
|
||||
|
||||
set -o errexit
|
||||
|
||||
die() {
|
||||
@ -12,12 +16,27 @@ die() {
|
||||
}
|
||||
|
||||
ko_to_test() {
|
||||
tmp=${1%.ko}-LOADED.test
|
||||
echo ${tmp#kpatch-}
|
||||
tmp=${1%${MODULE_POSTFIX}}${TEST_POSTFIX}
|
||||
echo ${tmp#${MODULE_PREFIX}}
|
||||
}
|
||||
|
||||
# make sure any modules added here are disjoint
|
||||
declare -a modules=(kpatch-cmdline-string.ko kpatch-meminfo-string.ko)
|
||||
declare -a modules
|
||||
declare -a blacklist=(meminfo-cmdline-rebuild-SLOW-LOADED.test)
|
||||
|
||||
for file in "${SCRIPTDIR}"/*"${TEST_POSTFIX}"; do
|
||||
name=$(basename ${file})
|
||||
skip=0
|
||||
for bname in "${blacklist[@]}"; do
|
||||
if [ "${bname}" == "${name}" ]; then
|
||||
skip=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ ${skip} -eq 0 ]; then
|
||||
modules+=(${MODULE_PREFIX}${name%${TEST_POSTFIX}}${MODULE_POSTFIX})
|
||||
fi
|
||||
done
|
||||
|
||||
for mod in "${modules[@]}"; do
|
||||
testprog=$(ko_to_test $mod)
|
||||
|
@ -1,7 +1,8 @@
|
||||
diff -Nupr src.orig/fs/proc/array.c src/fs/proc/array.c
|
||||
--- src.orig/fs/proc/array.c 2017-11-17 15:58:41.136211972 -0500
|
||||
+++ src/fs/proc/array.c 2017-11-17 15:59:36.184211972 -0500
|
||||
@@ -354,12 +354,19 @@ static inline void task_seccomp(struct s
|
||||
Index: src/fs/proc/array.c
|
||||
===================================================================
|
||||
--- src.orig/fs/proc/array.c
|
||||
+++ src/fs/proc/array.c
|
||||
@@ -363,12 +363,19 @@ static inline void task_seccomp(struct s
|
||||
seq_putc(m, '\n');
|
||||
}
|
||||
|
||||
@ -21,9 +22,10 @@ diff -Nupr src.orig/fs/proc/array.c src/fs/proc/array.c
|
||||
}
|
||||
|
||||
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 2017-11-17 15:58:51.659211972 -0500
|
||||
+++ src/kernel/exit.c 2017-11-17 15:59:36.184211972 -0500
|
||||
Index: src/kernel/exit.c
|
||||
===================================================================
|
||||
--- src.orig/kernel/exit.c
|
||||
+++ src/kernel/exit.c
|
||||
@@ -760,6 +760,7 @@ static void check_stack_usage(void)
|
||||
static inline void check_stack_usage(void) {}
|
||||
#endif
|
||||
@ -41,10 +43,11 @@ diff -Nupr src.orig/kernel/exit.c src/kernel/exit.c
|
||||
/*
|
||||
* 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 2017-11-17 15:58:51.541211972 -0500
|
||||
+++ src/kernel/fork.c 2017-11-17 15:59:36.184211972 -0500
|
||||
@@ -2003,6 +2003,7 @@ struct task_struct *fork_idle(int cpu)
|
||||
Index: src/kernel/fork.c
|
||||
===================================================================
|
||||
--- src.orig/kernel/fork.c
|
||||
+++ src/kernel/fork.c
|
||||
@@ -2062,6 +2062,7 @@ struct task_struct *fork_idle(int cpu)
|
||||
* It copies the process, and if successful kick-starts
|
||||
* it and waits for it to finish using the VM if required.
|
||||
*/
|
||||
@ -52,17 +55,24 @@ diff -Nupr src.orig/kernel/fork.c src/kernel/fork.c
|
||||
long _do_fork(unsigned long clone_flags,
|
||||
unsigned long stack_start,
|
||||
unsigned long stack_size,
|
||||
@@ -2042,6 +2043,13 @@ long _do_fork(unsigned long clone_flags,
|
||||
if (!IS_ERR(p)) {
|
||||
struct completion vfork;
|
||||
struct pid *pid;
|
||||
+ int *newpid;
|
||||
+ static int ctr = 0;
|
||||
@@ -2074,6 +2075,8 @@ long _do_fork(unsigned long clone_flags,
|
||||
struct task_struct *p;
|
||||
int trace = 0;
|
||||
long nr;
|
||||
+ int *newpid;
|
||||
+ static int ctr = 0;
|
||||
|
||||
/*
|
||||
* Determine whether and which event to report to ptracer. When
|
||||
@@ -2100,6 +2103,11 @@ long _do_fork(unsigned long clone_flags,
|
||||
if (IS_ERR(p))
|
||||
return PTR_ERR(p);
|
||||
|
||||
+ newpid = kpatch_shadow_alloc(p, "newpid", sizeof(*newpid),
|
||||
+ GFP_KERNEL);
|
||||
+ if (newpid)
|
||||
+ *newpid = ctr++;
|
||||
+
|
||||
+ newpid = kpatch_shadow_alloc(p, "newpid", sizeof(*newpid),
|
||||
+ GFP_KERNEL);
|
||||
+ if (newpid)
|
||||
+ *newpid = ctr++;
|
||||
|
||||
trace_sched_process_fork(current, p);
|
||||
|
||||
/*
|
||||
* Do this prior waking up the new thread - the thread pointer
|
||||
* might get invalid after that point, if the thread exits quickly.
|
||||
|
@ -206,7 +206,7 @@ run_load_test() {
|
||||
|
||||
run_custom_test() {
|
||||
testprog=$1
|
||||
prefix=$(basename ${file%%.test})
|
||||
prefix=$(basename ${testprog%%.test})
|
||||
|
||||
[[ $testprog = *-LOADED.test ]] && return
|
||||
|
||||
@ -310,15 +310,20 @@ run_combined_test
|
||||
|
||||
if [[ $QUICK != 1 ]]; then
|
||||
for testprog in "${TEST_LIST[@]}"; do
|
||||
unload_all
|
||||
run_custom_test $testprog
|
||||
if [[ ! $testprog =~ -FAIL ]]; then
|
||||
unload_all
|
||||
run_custom_test $testprog
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
unload_all
|
||||
|
||||
dmesg |grep -q "Call Trace" && error "kernel error detected in printk buffer"
|
||||
if dmesg | grep -q "Call Trace"; then
|
||||
dmesg > dmesg.log
|
||||
error "kernel error detected in printk buffer"
|
||||
fi
|
||||
|
||||
if [[ $ERROR -gt 0 ]]; then
|
||||
log "$ERROR errors encountered"
|
||||
|
@ -211,9 +211,6 @@ kpatch_write_vagrantfile_template()
|
||||
local target_distro=${1}
|
||||
|
||||
local box_prefix="kpatch"
|
||||
if [ "${target_distro}" == "centos7" ]; then
|
||||
box_prefix="generic"
|
||||
fi
|
||||
|
||||
cat >Vagrantfile <<EOF
|
||||
Vagrant.configure("2") do |config|
|
||||
|
@ -31,7 +31,7 @@ while [[ $# -gt 0 ]]; do
|
||||
shift
|
||||
done
|
||||
|
||||
declare -a distros=("fedora27" "ubuntu1604" "centos7")
|
||||
declare -a distros=("fedora27" "centos7")
|
||||
|
||||
ret=0
|
||||
for distro in "${distros[@]}"; do
|
||||
|
@ -1,6 +1,9 @@
|
||||
ensure that __cmpxchg_double_slab.isra.45 and
|
||||
__cmpxchg_double_slab.isra.45.part.46 aren't correlated.
|
||||
|
||||
Disabled: __flush_cpu_slab() is present in vmlinux.symtab but is optimized
|
||||
out during kpatch builds
|
||||
|
||||
diff -Nupr src.orig/mm/slub.c src/mm/slub.c
|
||||
--- src.orig/mm/slub.c 2016-12-15 19:55:38.988000000 +0000
|
||||
+++ src/mm/slub.c 2016-12-15 19:56:39.068000000 +0000
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
if $(nm kpatch-gcc-static-local-var-4.ko | grep -q free_ioctx); then
|
||||
if $(nm test-gcc-static-local-var-4.ko | grep -q free_ioctx); then
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
|
163
test/integration/ubuntu-16.04/macro-callbacks.patch
Normal file
163
test/integration/ubuntu-16.04/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.old/drivers/input/joydev.c src/drivers/input/joydev.c
|
||||
--- src.old/drivers/input/joydev.c 2017-09-03 16:56:17.000000000 -0400
|
||||
+++ src/drivers/input/joydev.c 2018-03-22 16:32:40.963082354 -0400
|
||||
@@ -1010,3 +1010,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.old/drivers/input/misc/pcspkr.c src/drivers/input/misc/pcspkr.c
|
||||
--- src.old/drivers/input/misc/pcspkr.c 2018-03-22 16:29:27.716082354 -0400
|
||||
+++ src/drivers/input/misc/pcspkr.c 2018-03-22 16:32:40.963082354 -0400
|
||||
@@ -132,3 +132,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.old/fs/aio.c src/fs/aio.c
|
||||
--- src.old/fs/aio.c 2017-09-03 16:56:17.000000000 -0400
|
||||
+++ src/fs/aio.c 2018-03-22 16:32:40.962082354 -0400
|
||||
@@ -46,6 +46,50 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
+#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
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
[[ $(cat /proc/sys/fs/aio-max-nr) = 262144 ]]
|
@ -1,24 +0,0 @@
|
||||
diff -Nupr src.orig/fs/aio.c src/fs/aio.c
|
||||
--- src.orig/fs/aio.c 2016-12-15 19:55:38.992000000 +0000
|
||||
+++ src/fs/aio.c 2016-12-15 19:57:05.396000000 +0000
|
||||
@@ -1716,6 +1716,20 @@ SYSCALL_DEFINE3(io_cancel, aio_context_t
|
||||
return ret;
|
||||
}
|
||||
|
||||
+static int aio_max_nr_orig;
|
||||
+void kpatch_load_aio_max_nr(void)
|
||||
+{
|
||||
+ aio_max_nr_orig = aio_max_nr;
|
||||
+ aio_max_nr = 0x40000;
|
||||
+}
|
||||
+void kpatch_unload_aio_max_nr(void)
|
||||
+{
|
||||
+ aio_max_nr = aio_max_nr_orig;
|
||||
+}
|
||||
+#include "kpatch-macros.h"
|
||||
+KPATCH_LOAD_HOOK(kpatch_load_aio_max_nr);
|
||||
+KPATCH_UNLOAD_HOOK(kpatch_unload_aio_max_nr);
|
||||
+
|
||||
/* io_getevents:
|
||||
* Attempts to read at least min_nr events and up to nr events from
|
||||
* the completion queue for the aio_context specified by ctx_id. If
|
@ -1,6 +1,7 @@
|
||||
diff -Nupr src.orig/net/ipv4/fib_frontend.c src/net/ipv4/fib_frontend.c
|
||||
--- src.orig/net/ipv4/fib_frontend.c 2016-12-15 19:55:39.724000000 +0000
|
||||
+++ src/net/ipv4/fib_frontend.c 2016-12-15 19:57:09.672000000 +0000
|
||||
Index: src/net/ipv4/fib_frontend.c
|
||||
===================================================================
|
||||
--- src.orig/net/ipv4/fib_frontend.c
|
||||
+++ src/net/ipv4/fib_frontend.c
|
||||
@@ -728,6 +728,7 @@ errout:
|
||||
return err;
|
||||
}
|
||||
@ -17,10 +18,11 @@ diff -Nupr src.orig/net/ipv4/fib_frontend.c src/net/ipv4/fib_frontend.c
|
||||
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 2016-12-15 19:55:39.720000000 +0000
|
||||
+++ src/net/ipv4/fib_semantics.c 2016-12-15 19:57:09.672000000 +0000
|
||||
@@ -991,6 +991,7 @@ fib_convert_metrics(struct fib_info *fi,
|
||||
Index: src/net/ipv4/fib_semantics.c
|
||||
===================================================================
|
||||
--- src.orig/net/ipv4/fib_semantics.c
|
||||
+++ src/net/ipv4/fib_semantics.c
|
||||
@@ -998,6 +998,7 @@ fib_convert_metrics(struct fib_info *fi,
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -28,7 +30,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
struct fib_info *fib_create_info(struct fib_config *cfg)
|
||||
{
|
||||
int err;
|
||||
@@ -1018,6 +1019,7 @@ struct fib_info *fib_create_info(struct
|
||||
@@ -1025,6 +1026,7 @@ struct fib_info *fib_create_info(struct
|
||||
#endif
|
||||
|
||||
err = -ENOBUFS;
|
||||
@ -36,7 +38,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
if (fib_info_cnt >= fib_info_hash_size) {
|
||||
unsigned int new_size = fib_info_hash_size << 1;
|
||||
struct hlist_head *new_info_hash;
|
||||
@@ -1038,6 +1040,7 @@ struct fib_info *fib_create_info(struct
|
||||
@@ -1045,6 +1047,7 @@ struct fib_info *fib_create_info(struct
|
||||
if (!fib_info_hash_size)
|
||||
goto failure;
|
||||
}
|
||||
@ -44,15 +46,15 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
|
||||
if (!fi)
|
||||
@@ -1049,6 +1052,7 @@ struct fib_info *fib_create_info(struct
|
||||
goto failure;
|
||||
} else
|
||||
fi->fib_metrics = (u32 *) dst_default_metrics;
|
||||
@@ -1059,6 +1062,7 @@ 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;
|
||||
@@ -1065,6 +1069,7 @@ struct fib_info *fib_create_info(struct
|
||||
@@ -1075,6 +1079,7 @@ struct fib_info *fib_create_info(struct
|
||||
if (!nexthop_nh->nh_pcpu_rth_output)
|
||||
goto failure;
|
||||
} endfor_nexthops(fi)
|
||||
@ -60,7 +62,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
err = fib_convert_metrics(fi, cfg);
|
||||
if (err)
|
||||
@@ -1117,6 +1122,8 @@ struct fib_info *fib_create_info(struct
|
||||
@@ -1127,6 +1132,8 @@ struct fib_info *fib_create_info(struct
|
||||
nh->nh_weight = 1;
|
||||
#endif
|
||||
}
|
||||
@ -69,7 +71,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
if (fib_props[cfg->fc_type].error) {
|
||||
if (cfg->fc_gw || cfg->fc_oif || cfg->fc_mp)
|
||||
@@ -1134,6 +1141,7 @@ struct fib_info *fib_create_info(struct
|
||||
@@ -1144,6 +1151,7 @@ struct fib_info *fib_create_info(struct
|
||||
goto err_inval;
|
||||
}
|
||||
}
|
||||
@ -77,7 +79,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
if (cfg->fc_scope > RT_SCOPE_HOST)
|
||||
goto err_inval;
|
||||
@@ -1162,6 +1170,7 @@ struct fib_info *fib_create_info(struct
|
||||
@@ -1172,6 +1180,7 @@ struct fib_info *fib_create_info(struct
|
||||
if (linkdown == fi->fib_nhs)
|
||||
fi->fib_flags |= RTNH_F_LINKDOWN;
|
||||
}
|
||||
@ -85,7 +87,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
if (fi->fib_prefsrc && !fib_valid_prefsrc(cfg, fi->fib_prefsrc))
|
||||
goto err_inval;
|
||||
@@ -1170,6 +1179,7 @@ struct fib_info *fib_create_info(struct
|
||||
@@ -1180,6 +1189,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)
|
||||
@ -93,7 +95,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
fib_rebalance(fi);
|
||||
|
||||
@@ -1181,6 +1191,7 @@ link_it:
|
||||
@@ -1191,6 +1201,7 @@ link_it:
|
||||
ofi->fib_treeref++;
|
||||
return ofi;
|
||||
}
|
||||
@ -101,7 +103,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
fi->fib_treeref++;
|
||||
atomic_inc(&fi->fib_clntref);
|
||||
@@ -1204,6 +1215,7 @@ link_it:
|
||||
@@ -1214,6 +1225,7 @@ link_it:
|
||||
hlist_add_head(&nexthop_nh->nh_hash, head);
|
||||
} endfor_nexthops(fi)
|
||||
spin_unlock_bh(&fib_info_lock);
|
||||
@ -109,7 +111,7 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
return fi;
|
||||
|
||||
err_inval:
|
||||
@@ -1214,6 +1226,7 @@ failure:
|
||||
@@ -1224,6 +1236,7 @@ failure:
|
||||
fi->fib_dead = 1;
|
||||
free_fib_info(fi);
|
||||
}
|
||||
@ -117,9 +119,10 @@ diff -Nupr src.orig/net/ipv4/fib_semantics.c src/net/ipv4/fib_semantics.c
|
||||
|
||||
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 2016-12-15 19:55:39.720000000 +0000
|
||||
+++ src/net/ipv4/fib_trie.c 2016-12-15 19:57:09.676000000 +0000
|
||||
Index: src/net/ipv4/fib_trie.c
|
||||
===================================================================
|
||||
--- src.orig/net/ipv4/fib_trie.c
|
||||
+++ src/net/ipv4/fib_trie.c
|
||||
@@ -1078,6 +1078,7 @@ static int fib_insert_alias(struct trie
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
Disabled:
|
||||
kpatch-build currently fails with "invalid ancestor" error. This happens
|
||||
with at least drivers/gpu/drm/i2c/adv7511.o and drivers/hwmon/htu21.o
|
||||
files. The problem is their .ko counterparts are never built for some
|
||||
reason, This looks like a kernel bug since in both cases there are files
|
||||
with same name but in different paths that have .ko module built.
|
||||
---
|
||||
diff -Nupr src.orig/fs/proc/cmdline.c src/fs/proc/cmdline.c
|
||||
--- src.orig/fs/proc/cmdline.c 2016-12-15 19:55:39.084000000 +0000
|
||||
+++ src/fs/proc/cmdline.c 2016-12-15 19:57:13.988000000 +0000
|
@ -1,3 +1,8 @@
|
||||
Disabled:
|
||||
Original build includes "kzalloc" in af_netlink.c's symbol list, this
|
||||
does not happen during kpatch build so create-diff-object fails with
|
||||
find_local_syms.
|
||||
---
|
||||
diff -Nupr src.orig/fs/nfsd/export.c src/fs/nfsd/export.c
|
||||
--- src.orig/fs/nfsd/export.c 2016-12-15 19:55:39.012000000 +0000
|
||||
+++ src/fs/nfsd/export.c 2016-12-15 19:57:31.068000000 +0000
|
@ -1,24 +0,0 @@
|
||||
diff -Nupr src.orig/arch/x86/kvm/vmx.c src/arch/x86/kvm/vmx.c
|
||||
--- src.orig/arch/x86/kvm/vmx.c 2016-12-15 19:55:57.436000000 +0000
|
||||
+++ src/arch/x86/kvm/vmx.c 2016-12-15 19:57:39.592000000 +0000
|
||||
@@ -10558,10 +10558,20 @@ static void vmx_leave_nested(struct kvm_
|
||||
* It should only be called before L2 actually succeeded to run, and when
|
||||
* vmcs01 is current (it doesn't leave_guest_mode() or switch vmcss).
|
||||
*/
|
||||
+#include "kpatch.h"
|
||||
static void nested_vmx_entry_failure(struct kvm_vcpu *vcpu,
|
||||
struct vmcs12 *vmcs12,
|
||||
u32 reason, unsigned long qualification)
|
||||
{
|
||||
+ int *kpatch;
|
||||
+
|
||||
+ kpatch = kpatch_shadow_alloc(vcpu, "kpatch", sizeof(*kpatch),
|
||||
+ GFP_KERNEL);
|
||||
+ if (kpatch) {
|
||||
+ kpatch_shadow_get(vcpu, "kpatch");
|
||||
+ kpatch_shadow_free(vcpu, "kpatch");
|
||||
+ }
|
||||
+
|
||||
load_vmcs12_host_state(vcpu, vmcs12);
|
||||
vmcs12->vm_exit_reason = reason | VMX_EXIT_REASONS_FAILED_VMENTRY;
|
||||
vmcs12->exit_qualification = qualification;
|
@ -4,6 +4,10 @@ SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))"
|
||||
ROOTDIR="$(readlink -f $SCRIPTDIR/../../..)"
|
||||
KPATCH="sudo $ROOTDIR/kpatch/kpatch"
|
||||
|
||||
MODULE_PREFIX="test-"
|
||||
MODULE_POSTFIX=".ko"
|
||||
TEST_POSTFIX="-LOADED.test"
|
||||
|
||||
set -o errexit
|
||||
|
||||
die() {
|
||||
@ -12,12 +16,27 @@ die() {
|
||||
}
|
||||
|
||||
ko_to_test() {
|
||||
tmp=${1%.ko}-LOADED.test
|
||||
echo ${tmp#kpatch-}
|
||||
tmp=${1%${MODULE_POSTFIX}}${TEST_POSTFIX}
|
||||
echo ${tmp#${MODULE_PREFIX}}
|
||||
}
|
||||
|
||||
# make sure any modules added here are disjoint
|
||||
declare -a modules=(kpatch-cmdline-string.ko kpatch-meminfo-string.ko)
|
||||
declare -a modules
|
||||
declare -a blacklist=(data-new-LOADED.test meminfo-cmdline-rebuild-SLOW-LOADED.test)
|
||||
|
||||
for file in "${SCRIPTDIR}"/*"${TEST_POSTFIX}"; do
|
||||
name=$(basename ${file})
|
||||
skip=0
|
||||
for bname in "${blacklist[@]}"; do
|
||||
if [ "${bname}" == "${name}" ]; then
|
||||
skip=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ ${skip} -eq 0 ]; then
|
||||
modules+=(${MODULE_PREFIX}${name%${TEST_POSTFIX}}${MODULE_POSTFIX})
|
||||
fi
|
||||
done
|
||||
|
||||
for mod in "${modules[@]}"; do
|
||||
testprog=$(ko_to_test $mod)
|
||||
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
grep -q newpid: /proc/$$/status
|
@ -1,69 +0,0 @@
|
||||
diff -Nupr src.orig/fs/proc/array.c src/fs/proc/array.c
|
||||
--- src.orig/fs/proc/array.c 2016-12-15 19:55:39.080000000 +0000
|
||||
+++ src/fs/proc/array.c 2016-12-15 19:58:00.840000000 +0000
|
||||
@@ -334,13 +334,20 @@ static inline void task_seccomp(struct s
|
||||
#endif
|
||||
}
|
||||
|
||||
+#include "kpatch.h"
|
||||
static inline void task_context_switch_counts(struct seq_file *m,
|
||||
struct task_struct *p)
|
||||
{
|
||||
+ int *newpid;
|
||||
+
|
||||
seq_printf(m, "voluntary_ctxt_switches:\t%lu\n"
|
||||
"nonvoluntary_ctxt_switches:\t%lu\n",
|
||||
p->nvcsw,
|
||||
p->nivcsw);
|
||||
+
|
||||
+ newpid = kpatch_shadow_get(p, "newpid");
|
||||
+ 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 2016-12-15 19:56:00.184000000 +0000
|
||||
+++ src/kernel/exit.c 2016-12-15 19:58:00.840000000 +0000
|
||||
@@ -650,6 +650,7 @@ static void check_stack_usage(void)
|
||||
static inline void check_stack_usage(void) {}
|
||||
#endif
|
||||
|
||||
+#include "kpatch.h"
|
||||
void do_exit(long code)
|
||||
{
|
||||
struct task_struct *tsk = current;
|
||||
@@ -758,6 +759,8 @@ void do_exit(long code)
|
||||
|
||||
cgroup_exit(tsk);
|
||||
|
||||
+ kpatch_shadow_free(tsk, "newpid");
|
||||
+
|
||||
/*
|
||||
* FIXME: do that only when needed, using sched_exit tracepoint
|
||||
*/
|
||||
diff -Nupr src.orig/kernel/fork.c src/kernel/fork.c
|
||||
--- src.orig/kernel/fork.c 2016-12-15 19:56:00.184000000 +0000
|
||||
+++ src/kernel/fork.c 2016-12-15 19:58:00.840000000 +0000
|
||||
@@ -1726,6 +1726,7 @@ struct task_struct *fork_idle(int cpu)
|
||||
* It copies the process, and if successful kick-starts
|
||||
* it and waits for it to finish using the VM if required.
|
||||
*/
|
||||
+#include "kpatch.h"
|
||||
long _do_fork(unsigned long clone_flags,
|
||||
unsigned long stack_start,
|
||||
unsigned long stack_size,
|
||||
@@ -1764,6 +1765,13 @@ long _do_fork(unsigned long clone_flags,
|
||||
if (!IS_ERR(p)) {
|
||||
struct completion vfork;
|
||||
struct pid *pid;
|
||||
+ int *newpid;
|
||||
+ static int ctr = 0;
|
||||
+
|
||||
+ newpid = kpatch_shadow_alloc(p, "newpid", sizeof(*newpid),
|
||||
+ GFP_KERNEL);
|
||||
+ if (newpid)
|
||||
+ *newpid = ctr++;
|
||||
|
||||
trace_sched_process_fork(current, p);
|
||||
|
@ -38,6 +38,13 @@ kpatch_dependencies
|
||||
kpatch_separate_disk_cache /dev/vdb /mnt/build
|
||||
kpatch_set_ccache_max_size 10G
|
||||
|
||||
# Check if we have predownloaded sources and move them to ~/.kpatch dir which
|
||||
# is a symlink to a dir on a separate (bigger) volume, suitable for building.
|
||||
if [[ -d "${HOME}/src" && -f "${HOME}/src/version" ]]; then
|
||||
cp "${HOME}/src/version" "${HOME}/.kpatch/"
|
||||
mv "${HOME}/src" "${HOME}/.kpatch/"
|
||||
fi
|
||||
|
||||
if [ ${KPATCH_SLOW} -eq 1 ]; then
|
||||
make integration-slow 2>&1
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user