integration/centos7: update shadow-newpid.patch

Switch to klp shadow-variable API.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
This commit is contained in:
Artem Savkov 2019-01-09 12:39:57 +01:00
parent 31f6b02279
commit 28a18efa21

View File

@ -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++;