Patchwork [092/145] printk: Fix rq->lock vs logbuf_lock unlock lock inversion

login
register
mail settings
Submitter Kamal Mostafa
Date July 17, 2013, 10:47 p.m.
Message ID <1374101277-7915-93-git-send-email-kamal@canonical.com>
Download mbox | patch
Permalink /patch/259865/
State New
Headers show

Comments

Kamal Mostafa - July 17, 2013, 10:47 p.m.
3.8.13.5 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: "Bu, Yitian" <ybu@qti.qualcomm.com>

commit dbda92d16f8655044e082930e4e9d244b87fde77 upstream.

commit 07354eb1a74d1 ("locking printk: Annotate logbuf_lock as raw")
reintroduced a lock inversion problem which was fixed in commit
0b5e1c5255 ("printk: Release console_sem after logbuf_lock"). This
happened probably when fixing up patch rejects.

Restore the ordering and unlock logbuf_lock before releasing
console_sem.

Signed-off-by: ybu <ybu@qti.qualcomm.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/E807E903FE6CBE4D95E420FBFCC273B827413C@nasanexd01h.na.qualcomm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 kernel/printk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/kernel/printk.c b/kernel/printk.c
index 0f0ac58..37425c3 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1367,9 +1367,9 @@  static int console_trylock_for_printk(unsigned int cpu)
 		}
 	}
 	logbuf_cpu = UINT_MAX;
+	raw_spin_unlock(&logbuf_lock);
 	if (wake)
 		up(&console_sem);
-	raw_spin_unlock(&logbuf_lock);
 	return retval;
 }