aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@mellanox.com>2020-02-27 16:36:51 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-04-13 13:18:07 +0200
commitf58649c6517a6b126c058388f6dd0764f782c30d (patch)
treef259b50b47d1a49cbeb5b32321f6314a9a7c8744
parent69eb0ff46c4f4ee3c98158580e5b948d36eaf4fa (diff)
downloadlinux-yocto-f58649c6517a6b126c058388f6dd0764f782c30d.tar.gz
linux-yocto-f58649c6517a6b126c058388f6dd0764f782c30d.tar.bz2
linux-yocto-f58649c6517a6b126c058388f6dd0764f782c30d.zip
RDMA/cma: Teach lockdep about the order of rtnl and lock
commit 32ac9e4399b12d3e54d312a0e0e30ed5cd19bd4e upstream. This lock ordering only happens when bonding is enabled and a certain bonding related event fires. However, since it can happen this is a global restriction on lock ordering. Teach lockdep about the order directly and unconditionally so bugs here are found quickly. See https://syzkaller.appspot.com/bug?extid=55de90ab5f44172b0c90 Link: https://lore.kernel.org/r/20200227203651.GA27185@ziepe.ca Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/infiniband/core/cma.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 2dec3a02ab9f..aa1d5496d563 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -4790,6 +4790,19 @@ static int __init cma_init(void)
{
int ret;
+ /*
+ * There is a rare lock ordering dependency in cma_netdev_callback()
+ * that only happens when bonding is enabled. Teach lockdep that rtnl
+ * must never be nested under lock so it can find these without having
+ * to test with bonding.
+ */
+ if (IS_ENABLED(CONFIG_LOCKDEP)) {
+ rtnl_lock();
+ mutex_lock(&lock);
+ mutex_unlock(&lock);
+ rtnl_unlock();
+ }
+
cma_wq = alloc_ordered_workqueue("rdma_cm", WQ_MEM_RECLAIM);
if (!cma_wq)
return -ENOMEM;