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

Packit Service da4517
Index: src/fs/proc/array.c
Packit Service da4517
===================================================================
Packit Service da4517
--- src.orig/fs/proc/array.c
Packit Service da4517
+++ src/fs/proc/array.c
Packit Service da4517
@@ -363,12 +363,19 @@ static inline void task_seccomp(struct s
Packit Service da4517
 	seq_putc(m, '\n');
Packit Service da4517
 }
Packit Service da4517
 
Packit Service da4517
+#include "kpatch.h"
Packit Service da4517
 static inline void task_context_switch_counts(struct seq_file *m,
Packit Service da4517
 						struct task_struct *p)
Packit Service da4517
 {
Packit Service da4517
+	int *newpid;
Packit Service da4517
+
Packit Service da4517
 	seq_put_decimal_ull(m, "voluntary_ctxt_switches:\t", p->nvcsw);
Packit Service da4517
 	seq_put_decimal_ull(m, "\nnonvoluntary_ctxt_switches:\t", p->nivcsw);
Packit Service da4517
 	seq_putc(m, '\n');
Packit Service da4517
+
Packit Service da4517
+	newpid = kpatch_shadow_get(p, "newpid");
Packit Service da4517
+	if (newpid)
Packit Service da4517
+		seq_printf(m, "newpid:\t%d\n", *newpid);
Packit Service da4517
 }
Packit Service da4517
 
Packit Service da4517
 static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
Packit Service da4517
Index: src/kernel/exit.c
Packit Service da4517
===================================================================
Packit Service da4517
--- src.orig/kernel/exit.c
Packit Service da4517
+++ src/kernel/exit.c
Packit Service da4517
@@ -760,6 +760,7 @@ static void check_stack_usage(void)
Packit Service da4517
 static inline void check_stack_usage(void) {}
Packit Service da4517
 #endif
Packit Service da4517
 
Packit Service da4517
+#include "kpatch.h"
Packit Service da4517
 void __noreturn do_exit(long code)
Packit Service da4517
 {
Packit Service da4517
 	struct task_struct *tsk = current;
Packit Service da4517
@@ -865,6 +866,8 @@ void __noreturn do_exit(long code)
Packit Service da4517
 	exit_task_work(tsk);
Packit Service da4517
 	exit_thread(tsk);
Packit Service da4517
 
Packit Service da4517
+	kpatch_shadow_free(tsk, "newpid");
Packit Service da4517
+
Packit Service da4517
 	/*
Packit Service da4517
 	 * Flush inherited counters to the parent - before the parent
Packit Service da4517
 	 * gets woken up by child-exit notifications.
Packit Service da4517
Index: src/kernel/fork.c
Packit Service da4517
===================================================================
Packit Service da4517
--- src.orig/kernel/fork.c
Packit Service da4517
+++ src/kernel/fork.c
Packit Service da4517
@@ -2062,6 +2062,7 @@ struct task_struct *fork_idle(int cpu)
Packit Service da4517
  * It copies the process, and if successful kick-starts
Packit Service da4517
  * it and waits for it to finish using the VM if required.
Packit Service da4517
  */
Packit Service da4517
+#include "kpatch.h"
Packit Service da4517
 long _do_fork(unsigned long clone_flags,
Packit Service da4517
 	      unsigned long stack_start,
Packit Service da4517
 	      unsigned long stack_size,
Packit Service da4517
@@ -2074,6 +2075,8 @@ long _do_fork(unsigned long clone_flags,
Packit Service da4517
 	struct task_struct *p;
Packit Service da4517
 	int trace = 0;
Packit Service da4517
 	long nr;
Packit Service da4517
+	int *newpid;
Packit Service da4517
+	static int ctr = 0;
Packit Service da4517
 
Packit Service da4517
 	/*
Packit Service da4517
 	 * Determine whether and which event to report to ptracer.  When
Packit Service da4517
@@ -2100,6 +2103,11 @@ long _do_fork(unsigned long clone_flags,
Packit Service da4517
 	if (IS_ERR(p))
Packit Service da4517
 		return PTR_ERR(p);
Packit Service da4517
 
Packit Service da4517
+	newpid = kpatch_shadow_alloc(p, "newpid", sizeof(*newpid),
Packit Service da4517
+				     GFP_KERNEL);
Packit Service da4517
+	if (newpid)
Packit Service da4517
+		*newpid = ctr++;
Packit Service da4517
+
Packit Service da4517
 	/*
Packit Service da4517
 	 * Do this prior waking up the new thread - the thread pointer
Packit Service da4517
 	 * might get invalid after that point, if the thread exits quickly.