Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4823683ybl; Wed, 22 Jan 2020 05:25:59 -0800 (PST) X-Google-Smtp-Source: APXvYqyglbc+le3t+22HxZgqjE++5R/FnFV5uT0es+4/VQ224QNY7qIXRp+fAm7JJD5i1u5j4wxk X-Received: by 2002:a54:408f:: with SMTP id i15mr6459265oii.64.1579699559262; Wed, 22 Jan 2020 05:25:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579699559; cv=none; d=google.com; s=arc-20160816; b=GYIDK0DEYj4pBsjBxiJhnxOyXTt0dDifuL/nDGBW66ff8ppnF4cpbM4fOU2cm+vzXI UQGTfMMgcEWQS7c+QohAP9IvKd0pWClWyIbzdQF2HkA6Zex66TSOz5n+CF5XT7o4h/Us ZIIRHlOpHE8kpDXQRErfy41xt40hCH9Ei70LZNuAM84K/BTpSrV5JspkB5b0zsBMnkzJ 08Z7Cxw/eq3jFvLJyHixHuXj+edA6XMO6jLDhNXoLfgZ6mzsnE/pb1IaU8+2+QIhwOY3 FWHy4+h+mDo0QqZa6Gk7Au89gXCyWq+9X3rr2bhOjoJmvW1ar5AYsmidpcLkJrhA0FJ5 pcfQ== 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=3IRtnu2ap/S0c8A71JR7nhcH8lzaldQGoAf6VOBZmwM=; b=LKE0HEk8cmO/AuzddEOZ2m7tjomk2mBMo7DWZFfaaY3Ug8//PlekkXJLNur2X3fRX5 blJVyAIw9OZkal4HSFoDivhL9OFISiYSSs80aNlenkfIn5mg23EzM1uIcyYcEDceNdjC 9GcSLiX9WXcXEuvNE/ZQQM4sAM3G2wfnaVCaEGWziEGaqg41CSbgV00lW9WcP/CRxbmU Oeg2UNwU9llscYZ9j6apSMW5aNO4Kc8f1SxngMAC6fIguTS81hk+Y/5xd5u9recqvHG8 1IkJjzBtBV8S//dUnbATZzwE0btLe1qAuZ8Jl7xvPeszpzWdiS4Sxn8In6/LQxj4GH2v qitw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mvjqqwSi; 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 b9si21151705oie.20.2020.01.22.05.25.47; Wed, 22 Jan 2020 05:25:59 -0800 (PST) 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=mvjqqwSi; 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 S1730785AbgAVNXl (ORCPT + 99 others); Wed, 22 Jan 2020 08:23:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:41978 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730415AbgAVNXi (ORCPT ); Wed, 22 Jan 2020 08:23:38 -0500 Received: from localhost (unknown [84.241.205.26]) (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 E5CA9205F4; Wed, 22 Jan 2020 13:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699417; bh=kn1xqeotbC/h612r6WLpR4VyIxOLd3ZFQEoq32Ro7Os=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mvjqqwSiTlfuECPaAfzAku2lJiNlV8oCFFIAy0E7oomdVPDFWjOGD8kctoBpzkVRU Dxblq5BJcXOnWgnGFMtvHEdMwLylDok2fKGP5UNpcEBVxBmOY/BdO5WL1pwguzLbqF 5dIKAa8zogLQEdSippLbT61AVll/K89COU8W2XLM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+4ec99438ed7450da6272@syzkaller.appspotmail.com, Taehee Yoo , Cong Wang , "David S. Miller" Subject: [PATCH 5.4 138/222] net: avoid updating qdisc_xmit_lock_key in netdev_update_lockdep_key() Date: Wed, 22 Jan 2020 10:28:44 +0100 Message-Id: <20200122092843.619836106@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@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: Cong Wang [ Upstream commit 53d374979ef147ab51f5d632dfe20b14aebeccd0 ] syzbot reported some bogus lockdep warnings, for example bad unlock balance in sch_direct_xmit(). They are due to a race condition between slow path and fast path, that is qdisc_xmit_lock_key gets re-registered in netdev_update_lockdep_key() on slow path, while we could still acquire the queue->_xmit_lock on fast path in this small window: CPU A CPU B __netif_tx_lock(); lockdep_unregister_key(qdisc_xmit_lock_key); __netif_tx_unlock(); lockdep_register_key(qdisc_xmit_lock_key); In fact, unlike the addr_list_lock which has to be reordered when the master/slave device relationship changes, queue->_xmit_lock is only acquired on fast path and only when NETIF_F_LLTX is not set, so there is likely no nested locking for it. Therefore, we can just get rid of re-registration of qdisc_xmit_lock_key. Reported-by: syzbot+4ec99438ed7450da6272@syzkaller.appspotmail.com Fixes: ab92d68fc22f ("net: core: add generic lockdep keys") Cc: Taehee Yoo Signed-off-by: Cong Wang Acked-by: Taehee Yoo Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/core/dev.c | 12 ------------ 1 file changed, 12 deletions(-) --- a/net/core/dev.c +++ b/net/core/dev.c @@ -8953,22 +8953,10 @@ static void netdev_unregister_lockdep_ke void netdev_update_lockdep_key(struct net_device *dev) { - struct netdev_queue *queue; - int i; - - lockdep_unregister_key(&dev->qdisc_xmit_lock_key); lockdep_unregister_key(&dev->addr_list_lock_key); - - lockdep_register_key(&dev->qdisc_xmit_lock_key); lockdep_register_key(&dev->addr_list_lock_key); lockdep_set_class(&dev->addr_list_lock, &dev->addr_list_lock_key); - for (i = 0; i < dev->num_tx_queues; i++) { - queue = netdev_get_tx_queue(dev, i); - - lockdep_set_class(&queue->_xmit_lock, - &dev->qdisc_xmit_lock_key); - } } EXPORT_SYMBOL(netdev_update_lockdep_key);