Home Home > GIT Browse > SLE12-SP3-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavidlohr Bueso <dbueso@suse.de>2019-02-18 12:48:17 -0800
committerDavidlohr Bueso <dbueso@suse.de>2019-02-18 12:48:30 -0800
commite2cf447bf0fc59b3651615ee120cd28c5172ca17 (patch)
tree19df1426ba9d31b77b2cd08c2cf54cc1721551ab
parentd81bb75167b0476f632d50581eb04f74af8dba3f (diff)
locking/rwsem: Fix (possible) missed wakeup (bsc#1050549).
-rw-r--r--patches.fixes/0001-locking-rwsem-Fix-possible-missed-wakeup.patch64
-rw-r--r--series.conf1
2 files changed, 65 insertions, 0 deletions
diff --git a/patches.fixes/0001-locking-rwsem-Fix-possible-missed-wakeup.patch b/patches.fixes/0001-locking-rwsem-Fix-possible-missed-wakeup.patch
new file mode 100644
index 0000000000..7d053c69de
--- /dev/null
+++ b/patches.fixes/0001-locking-rwsem-Fix-possible-missed-wakeup.patch
@@ -0,0 +1,64 @@
+From a9cf88b3740a83e0c3dc38f2ac41bccccbbe3332 Mon Sep 17 00:00:00 2001
+From: Xie Yongji <xieyongji@baidu.com>
+Date: Mon, 18 Feb 2019 09:49:40 -0800
+Subject: [PATCH 1/3] locking/rwsem: Fix (possible) missed wakeup
+Git-commit: e158488be27b157802753a59b336142dc0eb0380
+Patch-mainline: v5.0-rc4
+References: bsc#1050549
+
+Because wake_q_add() can imply an immediate wakeup (cmpxchg failure
+case), we must not rely on the wakeup being delayed. However, commit:
+
+ e38513905eea ("locking/rwsem: Rework zeroing reader waiter->task")
+
+relies on exactly that behaviour in that the wakeup must not happen
+until after we clear waiter->task.
+
+[ peterz: Added changelog. ]
+
+Signed-off-by: Xie Yongji <xieyongji@baidu.com>
+Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Fixes: e38513905eea ("locking/rwsem: Rework zeroing reader waiter->task")
+Link: https://lkml.kernel.org/r/1543495830-2644-1-git-send-email-xieyongji@baidu.com
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
+
+---
+ kernel/locking/rwsem-xadd.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/kernel/locking/rwsem-xadd.c b/kernel/locking/rwsem-xadd.c
+index 27316d8f7d87..1dad74958b1c 100644
+--- a/kernel/locking/rwsem-xadd.c
++++ b/kernel/locking/rwsem-xadd.c
+@@ -207,14 +207,21 @@ __rwsem_mark_wake(struct rw_semaphore *sem,
+ next = waiter->list.next;
+ tsk = waiter->task;
+
+- wake_q_add(wake_q, tsk);
++ get_task_struct(tsk);
+ /*
+- * Ensure that the last operation is setting the reader
++ * Ensure calling get_task_struct() before setting the reader
+ * waiter to nil such that rwsem_down_read_failed() cannot
+ * race with do_exit() by always holding a reference count
+ * to the task to wakeup.
+ */
+ smp_store_release(&waiter->task, NULL);
++ /*
++ * Ensure issuing the wakeup (either by us or someone else)
++ * after setting the reader waiter to nil.
++ */
++ wake_q_add(wake_q, tsk);
++ /* wake_q_add() already take the task ref */
++ put_task_struct(tsk);
+ } while (--loop);
+
+ sem->wait_list.next = next;
+--
+2.16.4
+
diff --git a/series.conf b/series.conf
index 986551f5f3..25ed369f82 100644
--- a/series.conf
+++ b/series.conf
@@ -24254,6 +24254,7 @@
patches.fixes/0001-sched-wake_q-Document-wake_q_add.patch
patches.fixes/0002-sched-wake_q-Fix-wakeup-ordering-for-wake_q.patch
patches.fixes/0002-futex-Fix-possible-missed-wakeup.patch
+ patches.fixes/0001-locking-rwsem-Fix-possible-missed-wakeup.patch
patches.arch/x86-pkeys-properly-copy-pkey-state-at-fork
patches.drivers/iommu-amd-call-free_iova_fast-with-pfn-in-map_sg
patches.drivers/iommu-amd-unmap-all-mapped-pages-in-error-path-of-map_sg