Home Home > GIT Browse > stable
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-08-16 22:01:45 +0200
committerJiri Slaby <jslaby@suse.cz>2019-08-16 22:25:10 +0200
commitb645a6fd9fcb94c244e2d0ac937b2755717f94af (patch)
tree3aadc72adbfba170423dd15eb6e047893ef987cc
parent4bcc02cae521466b61202c40588dc41f2d9448b9 (diff)
tty/ldsem, locking/rwsem: Add missing ACQUIRE to read_failed
sleep loop (bnc#1012628).
-rw-r--r--patches.kernel.org/5.2.9-111-tty-ldsem-locking-rwsem-Add-missing-ACQUIRE-to-.patch78
-rw-r--r--series.conf1
2 files changed, 79 insertions, 0 deletions
diff --git a/patches.kernel.org/5.2.9-111-tty-ldsem-locking-rwsem-Add-missing-ACQUIRE-to-.patch b/patches.kernel.org/5.2.9-111-tty-ldsem-locking-rwsem-Add-missing-ACQUIRE-to-.patch
new file mode 100644
index 0000000000..049fa19cd8
--- /dev/null
+++ b/patches.kernel.org/5.2.9-111-tty-ldsem-locking-rwsem-Add-missing-ACQUIRE-to-.patch
@@ -0,0 +1,78 @@
+From: Peter Zijlstra <peterz@infradead.org>
+Date: Thu, 18 Jul 2019 15:03:15 +0200
+Subject: [PATCH] tty/ldsem, locking/rwsem: Add missing ACQUIRE to read_failed
+ sleep loop
+References: bnc#1012628
+Patch-mainline: 5.2.9
+Git-commit: 952041a8639a7a3a73a2b6573cb8aa8518bc39f8
+
+[ Upstream commit 952041a8639a7a3a73a2b6573cb8aa8518bc39f8 ]
+
+While reviewing rwsem down_slowpath, Will noticed ldsem had a copy of
+a bug we just found for rwsem.
+
+ X = 0;
+
+ CPU0 CPU1
+
+ rwsem_down_read()
+ for (;;) {
+ set_current_state(TASK_UNINTERRUPTIBLE);
+
+ X = 1;
+ rwsem_up_write();
+ rwsem_mark_wake()
+ atomic_long_add(adjustment, &sem->count);
+ smp_store_release(&waiter->task, NULL);
+
+ if (!waiter.task)
+ break;
+
+ ...
+ }
+
+ r = X;
+
+Allows 'r == 0'.
+
+Reported-by: Will Deacon <will@kernel.org>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Acked-by: Will Deacon <will@kernel.org>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Peter Hurley <peter@hurleysoftware.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Fixes: 4898e640caf0 ("tty: Add timed, writer-prioritized rw semaphore")
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ drivers/tty/tty_ldsem.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/tty/tty_ldsem.c b/drivers/tty/tty_ldsem.c
+index 717292c1c0df..60ff236a3d63 100644
+--- a/drivers/tty/tty_ldsem.c
++++ b/drivers/tty/tty_ldsem.c
+@@ -93,8 +93,7 @@ static void __ldsem_wake_readers(struct ld_semaphore *sem)
+
+ list_for_each_entry_safe(waiter, next, &sem->read_wait, list) {
+ tsk = waiter->task;
+- smp_mb();
+- waiter->task = NULL;
++ smp_store_release(&waiter->task, NULL);
+ wake_up_process(tsk);
+ put_task_struct(tsk);
+ }
+@@ -194,7 +193,7 @@ down_read_failed(struct ld_semaphore *sem, long count, long timeout)
+ for (;;) {
+ set_current_state(TASK_UNINTERRUPTIBLE);
+
+- if (!waiter.task)
++ if (!smp_load_acquire(&waiter.task))
+ break;
+ if (!timeout)
+ break;
+--
+2.22.0
+
diff --git a/series.conf b/series.conf
index 563a54bd7a..58af4e93b6 100644
--- a/series.conf
+++ b/series.conf
@@ -1131,6 +1131,7 @@
patches.kernel.org/5.2.9-108-scsi-ibmvfc-fix-WARN_ON-during-event-pool-relea.patch
patches.kernel.org/5.2.9-109-scsi-scsi_dh_alua-always-use-a-2-second-delay-b.patch
patches.kernel.org/5.2.9-110-test_firmware-fix-a-memory-leak-bug.patch
+ patches.kernel.org/5.2.9-111-tty-ldsem-locking-rwsem-Add-missing-ACQUIRE-to-.patch
########################################################
# Build fixes that apply to the vanilla kernel too.