diff options
author | Paul Gortmaker <paul.gortmaker@windriver.com> | 2018-07-25 15:22:01 -0400 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2018-07-25 15:22:01 -0400 |
commit | cb1dbc6568b53b439d4163aa7a2f5fa56e3231c6 (patch) | |
tree | 2c5f0eff7fcc994016268bdf007dd62556cf5c83 | |
parent | 8b7fc0810667a7d29fc59d6bf754bc747c7ce91c (diff) | |
download | longterm-queue-4.12-cb1dbc6568b53b439d4163aa7a2f5fa56e3231c6.tar.gz |
IB: add fix for fixes
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
-rw-r--r-- | queue/IB-ipoib-Fix-lockdep-issue-found-on-ipoib_ib_dev_hea.patch | 99 | ||||
-rw-r--r-- | queue/series | 1 |
2 files changed, 100 insertions, 0 deletions
diff --git a/queue/IB-ipoib-Fix-lockdep-issue-found-on-ipoib_ib_dev_hea.patch b/queue/IB-ipoib-Fix-lockdep-issue-found-on-ipoib_ib_dev_hea.patch new file mode 100644 index 0000000..98de3d8 --- /dev/null +++ b/queue/IB-ipoib-Fix-lockdep-issue-found-on-ipoib_ib_dev_hea.patch @@ -0,0 +1,99 @@ +From 1f80bd6a6cc8358b81194e1f5fc16449947396ec Mon Sep 17 00:00:00 2001 +From: Alex Vesker <valex@mellanox.com> +Date: Thu, 21 Dec 2017 17:38:27 +0200 +Subject: [PATCH] IB/ipoib: Fix lockdep issue found on ipoib_ib_dev_heavy_flush + +commit 1f80bd6a6cc8358b81194e1f5fc16449947396ec upstream. + +The locking order of vlan_rwsem (LOCK A) and then rtnl (LOCK B), +contradicts other flows such as ipoib_open possibly causing a deadlock. +To prevent this deadlock heavy flush is called with RTNL locked and +only then tries to acquire vlan_rwsem. +This deadlock is possible only when there are child interfaces. + +[ 140.941758] ====================================================== +[ 140.946276] WARNING: possible circular locking dependency detected +[ 140.950950] 4.15.0-rc1+ #9 Tainted: G O +[ 140.954797] ------------------------------------------------------ +[ 140.959424] kworker/u32:1/146 is trying to acquire lock: +[ 140.963450] (rtnl_mutex){+.+.}, at: [<ffffffffc083516a>] __ipoib_ib_dev_flush+0x2da/0x4e0 [ib_ipoib] +[ 140.970006] +but task is already holding lock: +[ 140.975141] (&priv->vlan_rwsem){++++}, at: [<ffffffffc0834ee1>] __ipoib_ib_dev_flush+0x51/0x4e0 [ib_ipoib] +[ 140.982105] +which lock already depends on the new lock. +[ 140.990023] +the existing dependency chain (in reverse order) is: +[ 140.998650] +-> #1 (&priv->vlan_rwsem){++++}: +[ 141.005276] down_read+0x4d/0xb0 +[ 141.009560] ipoib_open+0xad/0x120 [ib_ipoib] +[ 141.014400] __dev_open+0xcb/0x140 +[ 141.017919] __dev_change_flags+0x1a4/0x1e0 +[ 141.022133] dev_change_flags+0x23/0x60 +[ 141.025695] devinet_ioctl+0x704/0x7d0 +[ 141.029156] sock_do_ioctl+0x20/0x50 +[ 141.032526] sock_ioctl+0x221/0x300 +[ 141.036079] do_vfs_ioctl+0xa6/0x6d0 +[ 141.039656] SyS_ioctl+0x74/0x80 +[ 141.042811] entry_SYSCALL_64_fastpath+0x1f/0x96 +[ 141.046891] +-> #0 (rtnl_mutex){+.+.}: +[ 141.051701] lock_acquire+0xd4/0x220 +[ 141.055212] __mutex_lock+0x88/0x970 +[ 141.058631] __ipoib_ib_dev_flush+0x2da/0x4e0 [ib_ipoib] +[ 141.063160] __ipoib_ib_dev_flush+0x71/0x4e0 [ib_ipoib] +[ 141.067648] process_one_work+0x1f5/0x610 +[ 141.071429] worker_thread+0x4a/0x3f0 +[ 141.074890] kthread+0x141/0x180 +[ 141.078085] ret_from_fork+0x24/0x30 +[ 141.081559] + +other info that might help us debug this: +[ 141.088967] Possible unsafe locking scenario: +[ 141.094280] CPU0 CPU1 +[ 141.097953] ---- ---- +[ 141.101640] lock(&priv->vlan_rwsem); +[ 141.104771] lock(rtnl_mutex); +[ 141.109207] lock(&priv->vlan_rwsem); +[ 141.114032] lock(rtnl_mutex); +[ 141.116800] + *** DEADLOCK *** + +Fixes: b4b678b06f6e ("IB/ipoib: Grab rtnl lock on heavy flush when calling ndo_open/stop") +Signed-off-by: Alex Vesker <valex@mellanox.com> +Signed-off-by: Leon Romanovsky <leon@kernel.org> +Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> + +diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c +index 3b96cdaf9a83..e6151a29c412 100644 +--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c ++++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c +@@ -1236,13 +1236,10 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, + ipoib_ib_dev_down(dev); + + if (level == IPOIB_FLUSH_HEAVY) { +- rtnl_lock(); + if (test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) + ipoib_ib_dev_stop(dev); + +- result = ipoib_ib_dev_open(dev); +- rtnl_unlock(); +- if (result) ++ if (ipoib_ib_dev_open(dev)) + return; + + if (netif_queue_stopped(dev)) +@@ -1282,7 +1279,9 @@ void ipoib_ib_dev_flush_heavy(struct work_struct *work) + struct ipoib_dev_priv *priv = + container_of(work, struct ipoib_dev_priv, flush_heavy); + ++ rtnl_lock(); + __ipoib_ib_dev_flush(priv, IPOIB_FLUSH_HEAVY, 0); ++ rtnl_unlock(); + } + + void ipoib_ib_dev_cleanup(struct net_device *dev) +-- +2.15.0 + diff --git a/queue/series b/queue/series index ff54199..41aa367 100644 --- a/queue/series +++ b/queue/series @@ -114,6 +114,7 @@ udf-Avoid-overflow-when-session-starts-at-large-offs.patch macvlan-Only-deliver-one-copy-of-the-frame-to-the-ma.patch RDMA-cma-Avoid-triggering-undefined-behavior.patch IB-ipoib-Grab-rtnl-lock-on-heavy-flush-when-calling-.patch +IB-ipoib-Fix-lockdep-issue-found-on-ipoib_ib_dev_hea.patch icmp-don-t-fail-on-fragment-reassembly-time-exceeded.patch lightnvm-pblk-fix-changing-GC-group-list-for-a-line.patch lightnvm-pblk-initialize-debug-stat-counter.patch |