diff options
author | Paul Gortmaker <paul.gortmaker@windriver.com> | 2016-08-25 10:13:45 -0400 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2016-08-25 10:13:45 -0400 |
commit | 2a5e56876610fc1ffbe4059125fb3df91a33b24a (patch) | |
tree | 041553ccb622510115e775000daf048cd69af774 | |
parent | 25078b70e5b90fd2f8fb40d3bef18e9c05719900 (diff) | |
download | 4.8-rt-patches-2a5e56876610fc1ffbe4059125fb3df91a33b24a.tar.gz |
trace context fix
-rw-r--r-- | patches/ptrace-fix-ptrace-vs-tasklist_lock-race.patch | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/patches/ptrace-fix-ptrace-vs-tasklist_lock-race.patch b/patches/ptrace-fix-ptrace-vs-tasklist_lock-race.patch index 3cb6bb7003cf20..96dadfaa2458d9 100644 --- a/patches/ptrace-fix-ptrace-vs-tasklist_lock-race.patch +++ b/patches/ptrace-fix-ptrace-vs-tasklist_lock-race.patch @@ -1,6 +1,7 @@ +From b91712c92c5021104373780c8ff8d9e037af1672 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Date: Thu, 29 Aug 2013 18:21:04 +0200 -Subject: ptrace: fix ptrace vs tasklist_lock race +Subject: [PATCH] ptrace: fix ptrace vs tasklist_lock race As explained by Alexander Fyodorov <halcy@yandex.ru>: @@ -22,15 +23,12 @@ taken in case the caller is interrupted between looking into ->state and ->saved_state. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> ---- - include/linux/sched.h | 48 +++++++++++++++++++++++++++++++++++++++++++++--- - kernel/ptrace.c | 9 ++++++++- - kernel/sched/core.c | 17 +++++++++++++++-- - 3 files changed, 68 insertions(+), 6 deletions(-) +diff --git a/include/linux/sched.h b/include/linux/sched.h +index e9bf7e86b896..6f779056ea0e 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h -@@ -241,10 +241,7 @@ extern char ___assert_task_state[1 - 2*! +@@ -242,10 +242,7 @@ extern char ___assert_task_state[1 - 2*!!( TASK_UNINTERRUPTIBLE | __TASK_STOPPED | \ __TASK_TRACED | EXIT_ZOMBIE | EXIT_DEAD) @@ -41,7 +39,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> #define task_contributes_to_load(task) \ ((task->state & TASK_UNINTERRUPTIBLE) != 0 && \ (task->flags & PF_FROZEN) == 0 && \ -@@ -3026,6 +3023,51 @@ static inline int signal_pending_state(l +@@ -3132,6 +3129,51 @@ static inline int signal_pending_state(long state, struct task_struct *p) return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p); } @@ -93,9 +91,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> /* * cond_resched() and cond_resched_lock(): latency reduction via * explicit rescheduling in places that are safe. The return +diff --git a/kernel/ptrace.c b/kernel/ptrace.c +index d49bfa1e53e6..b8cf7a82f4e2 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c -@@ -128,7 +128,14 @@ static bool ptrace_freeze_traced(struct +@@ -128,7 +128,14 @@ static bool ptrace_freeze_traced(struct task_struct *task) spin_lock_irq(&task->sighand->siglock); if (task_is_traced(task) && !__fatal_signal_pending(task)) { @@ -111,9 +111,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> ret = true; } spin_unlock_irq(&task->sighand->siglock); +diff --git a/kernel/sched/core.c b/kernel/sched/core.c +index 143f4928267b..496323a8d432 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -1317,6 +1317,18 @@ int migrate_swap(struct task_struct *cur +@@ -1372,6 +1372,18 @@ out: return ret; } @@ -132,7 +134,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> /* * wait_task_inactive - wait for a thread to unschedule. * -@@ -1361,7 +1373,7 @@ unsigned long wait_task_inactive(struct +@@ -1416,7 +1428,7 @@ unsigned long wait_task_inactive(struct task_struct *p, long match_state) * is actually now running somewhere else! */ while (task_running(rq, p)) { @@ -141,7 +143,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> return 0; cpu_relax(); } -@@ -1376,7 +1388,8 @@ unsigned long wait_task_inactive(struct +@@ -1431,7 +1443,8 @@ unsigned long wait_task_inactive(struct task_struct *p, long match_state) running = task_running(rq, p); queued = task_on_rq_queued(p); ncsw = 0; @@ -149,5 +151,8 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> + if (!match_state || p->state == match_state || + p->saved_state == match_state) ncsw = p->nvcsw | LONG_MIN; /* sets MSB */ - task_rq_unlock(rq, p, &flags); + task_rq_unlock(rq, p, &rf); +-- +2.5.0 + |