Blame test/integration/fedora-27/shadow-newpid.patch

Packit Service ac8aad
diff -Nupr src.orig/fs/proc/array.c src/fs/proc/array.c
Packit Service ac8aad
--- src.orig/fs/proc/array.c	2017-11-17 15:58:41.136211972 -0500
Packit Service ac8aad
+++ src/fs/proc/array.c	2017-11-17 15:59:36.184211972 -0500
Packit Service ac8aad
@@ -354,12 +354,19 @@ static inline void task_seccomp(struct s
Packit Service ac8aad
 	seq_putc(m, '\n');
Packit Service ac8aad
 }
Packit Service ac8aad
 
Packit Service ac8aad
+#include "kpatch.h"
Packit Service ac8aad
 static inline void task_context_switch_counts(struct seq_file *m,
Packit Service ac8aad
 						struct task_struct *p)
Packit Service ac8aad
 {
Packit Service ac8aad
+	int *newpid;
Packit Service ac8aad
+
Packit Service ac8aad
 	seq_put_decimal_ull(m, "voluntary_ctxt_switches:\t", p->nvcsw);
Packit Service ac8aad
 	seq_put_decimal_ull(m, "\nnonvoluntary_ctxt_switches:\t", p->nivcsw);
Packit Service ac8aad
 	seq_putc(m, '\n');
Packit Service ac8aad
+
Packit Service ac8aad
+	newpid = kpatch_shadow_get(p, "newpid");
Packit Service ac8aad
+	if (newpid)
Packit Service ac8aad
+		seq_printf(m, "newpid:\t%d\n", *newpid);
Packit Service ac8aad
 }
Packit Service ac8aad
 
Packit Service ac8aad
 static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
Packit Service ac8aad
diff -Nupr src.orig/kernel/exit.c src/kernel/exit.c
Packit Service ac8aad
--- src.orig/kernel/exit.c	2017-11-17 15:58:51.659211972 -0500
Packit Service ac8aad
+++ src/kernel/exit.c	2017-11-17 15:59:36.184211972 -0500
Packit Service ac8aad
@@ -760,6 +760,7 @@ static void check_stack_usage(void)
Packit Service ac8aad
 static inline void check_stack_usage(void) {}
Packit Service ac8aad
 #endif
Packit Service ac8aad
 
Packit Service ac8aad
+#include "kpatch.h"
Packit Service ac8aad
 void __noreturn do_exit(long code)
Packit Service ac8aad
 {
Packit Service ac8aad
 	struct task_struct *tsk = current;
Packit Service ac8aad
@@ -865,6 +866,8 @@ void __noreturn do_exit(long code)
Packit Service ac8aad
 	exit_task_work(tsk);
Packit Service ac8aad
 	exit_thread(tsk);
Packit Service ac8aad
 
Packit Service ac8aad
+	kpatch_shadow_free(tsk, "newpid");
Packit Service ac8aad
+
Packit Service ac8aad
 	/*
Packit Service ac8aad
 	 * Flush inherited counters to the parent - before the parent
Packit Service ac8aad
 	 * gets woken up by child-exit notifications.
Packit Service ac8aad
diff -Nupr src.orig/kernel/fork.c src/kernel/fork.c
Packit Service ac8aad
--- src.orig/kernel/fork.c	2017-11-17 15:58:51.541211972 -0500
Packit Service ac8aad
+++ src/kernel/fork.c	2017-11-17 15:59:36.184211972 -0500
Packit Service ac8aad
@@ -2003,6 +2003,7 @@ struct task_struct *fork_idle(int cpu)
Packit Service ac8aad
  * It copies the process, and if successful kick-starts
Packit Service ac8aad
  * it and waits for it to finish using the VM if required.
Packit Service ac8aad
  */
Packit Service ac8aad
+#include "kpatch.h"
Packit Service ac8aad
 long _do_fork(unsigned long clone_flags,
Packit Service ac8aad
 	      unsigned long stack_start,
Packit Service ac8aad
 	      unsigned long stack_size,
Packit Service ac8aad
@@ -2042,6 +2043,13 @@ long _do_fork(unsigned long clone_flags,
Packit Service ac8aad
 	if (!IS_ERR(p)) {
Packit Service ac8aad
 		struct completion vfork;
Packit Service ac8aad
 		struct pid *pid;
Packit Service ac8aad
+		int *newpid;
Packit Service ac8aad
+		static int ctr = 0;
Packit Service ac8aad
+
Packit Service ac8aad
+		newpid = kpatch_shadow_alloc(p, "newpid", sizeof(*newpid),
Packit Service ac8aad
+					     GFP_KERNEL);
Packit Service ac8aad
+		if (newpid)
Packit Service ac8aad
+			*newpid = ctr++;
Packit Service ac8aad
 
Packit Service ac8aad
 		trace_sched_process_fork(current, p);
Packit Service ac8aad