| 1 |
Disabled due to https://github.com/dynup/kpatch/issues/940 |
| 2 |
--- |
| 3 |
diff --git a/fs/proc/array.c b/fs/proc/array.c |
| 4 |
index 0ceb3b6..1b44c7f 100644 |
| 5 |
--- a/fs/proc/array.c |
| 6 |
+++ b/fs/proc/array.c |
| 7 |
@@ -370,12 +370,19 @@ static inline void task_seccomp(struct seq_file *m, struct task_struct *p) |
| 8 |
seq_putc(m, '\n'); |
| 9 |
} |
| 10 |
|
| 11 |
+#include <linux/livepatch.h> |
| 12 |
static inline void task_context_switch_counts(struct seq_file *m, |
| 13 |
struct task_struct *p) |
| 14 |
{ |
| 15 |
+ int *newpid; |
| 16 |
+ |
| 17 |
seq_put_decimal_ull(m, "voluntary_ctxt_switches:\t", p->nvcsw); |
| 18 |
seq_put_decimal_ull(m, "\nnonvoluntary_ctxt_switches:\t", p->nivcsw); |
| 19 |
seq_putc(m, '\n'); |
| 20 |
+ |
| 21 |
+ newpid = klp_shadow_get(p, 0); |
| 22 |
+ if (newpid) |
| 23 |
+ seq_printf(m, "newpid:\t%d\n", *newpid); |
| 24 |
} |
| 25 |
|
| 26 |
static void task_cpus_allowed(struct seq_file *m, struct task_struct *task) |
| 27 |
diff --git a/kernel/exit.c b/kernel/exit.c |
| 28 |
index deaa53a..01f5776 100644 |
| 29 |
--- a/kernel/exit.c |
| 30 |
+++ b/kernel/exit.c |
| 31 |
@@ -760,6 +760,7 @@ static void check_stack_usage(void) |
| 32 |
static inline void check_stack_usage(void) {} |
| 33 |
#endif |
| 34 |
|
| 35 |
+#include <linux/livepatch.h> |
| 36 |
void __noreturn do_exit(long code) |
| 37 |
{ |
| 38 |
struct task_struct *tsk = current; |
| 39 |
@@ -865,6 +866,8 @@ void __noreturn do_exit(long code) |
| 40 |
exit_task_work(tsk); |
| 41 |
exit_thread(tsk); |
| 42 |
|
| 43 |
+ klp_shadow_free(tsk, 0, NULL); |
| 44 |
+ |
| 45 |
/* |
| 46 |
* Flush inherited counters to the parent - before the parent |
| 47 |
* gets woken up by child-exit notifications. |
| 48 |
diff --git a/kernel/fork.c b/kernel/fork.c |
| 49 |
index 3311231..2c12c1a 100644 |
| 50 |
--- a/kernel/fork.c |
| 51 |
+++ b/kernel/fork.c |
| 52 |
@@ -2093,6 +2093,7 @@ struct task_struct *fork_idle(int cpu) |
| 53 |
* It copies the process, and if successful kick-starts |
| 54 |
* it and waits for it to finish using the VM if required. |
| 55 |
*/ |
| 56 |
+#include <linux/livepatch.h> |
| 57 |
long _do_fork(unsigned long clone_flags, |
| 58 |
unsigned long stack_start, |
| 59 |
unsigned long stack_size, |
| 60 |
@@ -2105,6 +2106,8 @@ long _do_fork(unsigned long clone_flags, |
| 61 |
struct task_struct *p; |
| 62 |
int trace = 0; |
| 63 |
long nr; |
| 64 |
+ int *newpid; |
| 65 |
+ static int ctr = 0; |
| 66 |
|
| 67 |
/* |
| 68 |
* Determine whether and which event to report to ptracer. When |
| 69 |
@@ -2131,6 +2134,11 @@ long _do_fork(unsigned long clone_flags, |
| 70 |
if (IS_ERR(p)) |
| 71 |
return PTR_ERR(p); |
| 72 |
|
| 73 |
+ newpid = klp_shadow_get_or_alloc(p, 0, sizeof(*newpid), GFP_KERNEL, |
| 74 |
+ NULL, NULL); |
| 75 |
+ if (newpid) |
| 76 |
+ *newpid = ctr++; |
| 77 |
+ |
| 78 |
/* |
| 79 |
* Do this prior waking up the new thread - the thread pointer |
| 80 |
* might get invalid after that point, if the thread exits quickly. |