[linux] 01/01: locking/mutex: Don't assume TASK_RUNNING (Closes: #841171)

debian-kernel at lists.debian.org debian-kernel at lists.debian.org
Sun Jan 1 22:45:17 UTC 2017


This is an automated email from the git hooks/post-receive script.

benh pushed a commit to branch jessie
in repository linux.

commit 502fe3dc8371d10973a08188d998958b256e3d93
Author: Ben Hutchings <ben at decadent.org.uk>
Date:   Sun Jan 1 22:45:13 2017 +0000

    locking/mutex: Don't assume TASK_RUNNING (Closes: #841171)
---
 debian/changelog                                   |  6 +++
 .../locking-mutex-don-t-assume-task_running.patch  | 49 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 3 files changed, 56 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 3b18875..2cc7b41 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+linux (3.16.39-2) UNRELEASED; urgency=medium
+
+  * locking/mutex: Don't assume TASK_RUNNING (Closes: #841171)
+
+ -- Ben Hutchings <ben at decadent.org.uk>  Sun, 01 Jan 2017 22:44:31 +0000
+
 linux (3.16.39-1) jessie; urgency=medium
 
   * New upstream stable update:
diff --git a/debian/patches/bugfix/all/locking-mutex-don-t-assume-task_running.patch b/debian/patches/bugfix/all/locking-mutex-don-t-assume-task_running.patch
new file mode 100644
index 0000000..29ba676
--- /dev/null
+++ b/debian/patches/bugfix/all/locking-mutex-don-t-assume-task_running.patch
@@ -0,0 +1,49 @@
+From: Peter Zijlstra <peterz at infradead.org>
+Date: Wed, 24 Sep 2014 10:18:46 +0200
+Subject: locking/mutex: Don't assume TASK_RUNNING
+Origin: https://git.kernel.org/linus/6f942a1f264e875c5f3ad6f505d7b500a3e7fa82
+Bug-Debian: https://bugs.debian.org/841171
+
+We're going to make might_sleep() test for TASK_RUNNING, because
+blocking without TASK_RUNNING will destroy the task state by setting
+it to TASK_RUNNING.
+
+There are a few occasions where its 'valid' to call blocking
+primitives (and mutex_lock in particular) and not have TASK_RUNNING,
+typically such cases are right before we set TASK_RUNNING anyhow.
+
+Robustify the code by not assuming this; this has the beneficial side
+effect of allowing optional code emission for fixing the above
+might_sleep() false positives.
+
+Signed-off-by: Peter Zijlstra (Intel) <peterz at infradead.org>
+Cc: tglx at linutronix.de
+Cc: ilya.dryomov at inktank.com
+Cc: umgwanakikbuti at gmail.com
+Cc: Oleg Nesterov <oleg at redhat.com>
+Cc: Linus Torvalds <torvalds at linux-foundation.org>
+Link: http://lkml.kernel.org/r/20140924082241.988560063@infradead.org
+Signed-off-by: Ingo Molnar <mingo at kernel.org>
+[bwh: Backported to 3.16: adjust context]
+---
+ kernel/locking/mutex.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+--- a/kernel/locking/mutex.c
++++ b/kernel/locking/mutex.c
+@@ -480,8 +480,14 @@ static bool mutex_optimistic_spin(struct mutex *lock,
+ 	 * reschedule now, before we try-lock the mutex. This avoids getting
+ 	 * scheduled out right after we obtained the mutex.
+ 	 */
+-	if (need_resched())
++	if (need_resched()) {
++		/*
++		 * We _should_ have TASK_RUNNING here, but just in case
++		 * we do not, make it so, otherwise we might get stuck.
++		 */
++		__set_current_state(TASK_RUNNING);
+ 		schedule_preempt_disabled();
++	}
+ #endif
+ 	spin_lock_mutex(&lock->wait_lock, flags);
+ 
diff --git a/debian/patches/series b/debian/patches/series
index 558cb57..a7d60db 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -248,6 +248,7 @@ bugfix/all/fs-give-dentry-to-inode_change_ok-instead-of-inode.patch
 bugfix/all/-xen-blkfront-fix-accounting-of-reqs-when-migrating.patch
 
 # memfd_create() & kdbus backport
+bugfix/all/locking-mutex-don-t-assume-task_running.patch
 features/all/kdbus/mm-allow-drivers-to-prevent-new-writable-mappings.patch
 features/all/kdbus/shm-add-sealing-API.patch
 features/all/kdbus/shm-add-memfd_create-syscall.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/linux.git



More information about the Kernel-svn-changes mailing list