2018-11-30 13:34:55 +00:00
|
|
|
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
|
2017-11-27 19:14:24 +00:00
|
|
|
seq_putc(m, '\n');
|
2014-08-29 16:27:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+#include "kpatch.h"
|
|
|
|
static inline void task_context_switch_counts(struct seq_file *m,
|
|
|
|
struct task_struct *p)
|
|
|
|
{
|
|
|
|
+ int *newpid;
|
|
|
|
+
|
2017-02-08 22:14:32 +00:00
|
|
|
seq_put_decimal_ull(m, "voluntary_ctxt_switches:\t", p->nvcsw);
|
|
|
|
seq_put_decimal_ull(m, "\nnonvoluntary_ctxt_switches:\t", p->nivcsw);
|
|
|
|
seq_putc(m, '\n');
|
2014-08-29 16:27:33 +00:00
|
|
|
+
|
|
|
|
+ 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)
|
2018-11-30 13:34:55 +00:00
|
|
|
Index: src/kernel/exit.c
|
|
|
|
===================================================================
|
|
|
|
--- src.orig/kernel/exit.c
|
|
|
|
+++ src/kernel/exit.c
|
2017-11-27 19:14:24 +00:00
|
|
|
@@ -760,6 +760,7 @@ static void check_stack_usage(void)
|
2014-08-29 16:27:33 +00:00
|
|
|
static inline void check_stack_usage(void) {}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#include "kpatch.h"
|
2017-02-08 22:14:32 +00:00
|
|
|
void __noreturn do_exit(long code)
|
2014-08-29 16:27:33 +00:00
|
|
|
{
|
|
|
|
struct task_struct *tsk = current;
|
2017-11-27 19:14:24 +00:00
|
|
|
@@ -865,6 +866,8 @@ void __noreturn do_exit(long code)
|
2014-08-29 16:27:33 +00:00
|
|
|
exit_task_work(tsk);
|
2016-12-05 14:43:22 +00:00
|
|
|
exit_thread(tsk);
|
2014-08-29 16:27:33 +00:00
|
|
|
|
|
|
|
+ kpatch_shadow_free(tsk, "newpid");
|
|
|
|
+
|
|
|
|
/*
|
|
|
|
* Flush inherited counters to the parent - before the parent
|
|
|
|
* gets woken up by child-exit notifications.
|
2018-11-30 13:34:55 +00:00
|
|
|
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)
|
2016-12-05 14:43:22 +00:00
|
|
|
* 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,
|
2018-11-30 13:34:55 +00:00
|
|
|
@@ -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;
|
2016-12-05 14:43:22 +00:00
|
|
|
|
2018-11-30 13:34:55 +00:00
|
|
|
/*
|
|
|
|
* 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);
|
2016-12-05 14:43:22 +00:00
|
|
|
|
2018-11-30 13:34:55 +00:00
|
|
|
+ newpid = kpatch_shadow_alloc(p, "newpid", sizeof(*newpid),
|
|
|
|
+ GFP_KERNEL);
|
|
|
|
+ if (newpid)
|
|
|
|
+ *newpid = ctr++;
|
|
|
|
+
|
|
|
|
/*
|
|
|
|
* Do this prior waking up the new thread - the thread pointer
|
|
|
|
* might get invalid after that point, if the thread exits quickly.
|