Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1517026ybb; Sat, 11 Apr 2020 05:27:16 -0700 (PDT) X-Google-Smtp-Source: APiQypKK1L/04DIRpw9JNhRIisZ9nsxB3GkAv4FmPp1mOuD5A4o7wT0l1o6CGMFFEy9F8+l2fNCt X-Received: by 2002:a37:2714:: with SMTP id n20mr5567740qkn.291.1586608036447; Sat, 11 Apr 2020 05:27:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586608036; cv=none; d=google.com; s=arc-20160816; b=TgW59pdNI6wCmt4Bq80eg4eFUqmN+SHOnr52B06Gj4q0IBjdR7V/PCzn/qBXwcmHSD lLolQwsIaWY62cYgh9JAvyycYe+170uWiaF8+9j7py319QmfZPpaxHSr3DzfL5HIHZxW KCd/QOy9FiYJ+bNhb5iUnK5gIsy9LUnk0D9dRAwlSJG7hlLXGVXGrAVCXHgODQLByepb WiUNRLntvDQfSn1YlhVnLB0Lm6er8HksXfxRmm//v+k5trzHKPt9D9ihQ8WQawUq8XMT Wkf58/QHOFouEtidON8Yj3BscNuIzPn9TIJ3XVzel9LYkAbR7p8tFUFos5hvI/6ZYSYw XBXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RZ+6+9mXS42QyWOmCL8Pg+Xs+ObJodBHoHa7AaTrYdo=; b=GXMIqvnI9ZSn3Ds/9TjRCtDW5/IR31OTpfeC8MWLWECxiorFnXjnOx3sOmi5cp86s9 bLrggJstIYOz0x/E0x0kCrAR0OzTOQiyOZhzKUT8rX6aCUkK/bXSoNAkfyjexw4Qs1yC mZWcQCgWmfhlUfjr6+m8bhDlvawNFqrWp1rIXOaDSIND2wZxe4JDjdEGyLX1sD/xvsCo ouE1B1/Dv3s1oyrNwi3wLTnzwFbsit7IYA55Y3kEfBlaIQuTYZWLAWQbiLH/KGbMHx35 WSsE56x39x8VnGFUukKS/LKwmWMGdyWQ1T+kKpFOQdeHUOEOzgwPM40aQqSMKxYn8R1F Aq8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JBSvZBrC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v137si2898764qkb.289.2020.04.11.05.27.02; Sat, 11 Apr 2020 05:27:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JBSvZBrC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727049AbgDKMQM (ORCPT + 99 others); Sat, 11 Apr 2020 08:16:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:50334 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727974AbgDKMQJ (ORCPT ); Sat, 11 Apr 2020 08:16:09 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1D2D221744; Sat, 11 Apr 2020 12:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586607368; bh=67LXw2T1Q5Xxds2H0TR+DgKNBIZV5hKGpkb0wzIGYdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JBSvZBrCIXzDMorzfeumYRBHmlFZESkLAj/kf5r25ouRrwgm+AWALTEmzXBP5BFt/ 1spgwxP6vNHGQUySuWGf2DIlWaBep+l37kzDDoKodXRPrhNljt36YeRIaldIKUeN0L 4u4XfDiSgHftiz8lOx5voUKYkG6XYfQn/OqOlUUU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Gunthorpe Subject: [PATCH 4.19 45/54] RDMA/cma: Teach lockdep about the order of rtnl and lock Date: Sat, 11 Apr 2020 14:09:27 +0200 Message-Id: <20200411115513.221115209@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200411115508.284500414@linuxfoundation.org> References: <20200411115508.284500414@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Gunthorpe 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 Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/cma.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -4635,6 +4635,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;