Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2658845pxa; Mon, 17 Aug 2020 15:46:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMwAd9Gyrd6stOP5KoTSOWw6/ZkWO/mfVHfaPFO4fI9/ppfuYpxrTGr9ytD0Qwknc5oDjC X-Received: by 2002:a17:906:80c:: with SMTP id e12mr17663345ejd.128.1597704363766; Mon, 17 Aug 2020 15:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704363; cv=none; d=google.com; s=arc-20160816; b=fgu9kjBfCfEGCfIi3G6nE2T5MGh2jas/afrwSwrlrlpCByXyfqMvMfbZxF+brw7AOW lWyUMPPlKmeGZOFo+h291jbLjNFqOx+ergln1xdaBQVi+C8a++XHTM9dcJ8yUEhRKf26 zUz38fqzQC7JD3crBrP192KMr7947PPqnNBwSpZqQZuINFFyuc46QLIWMriOnMYT/goQ pleFgWI3+bbNt6kFFOx870M2CMpl+0K9wJtC3f0SVcwZp9EUPNAOpeFy6TwQCmHdIkYr Nd2l1VnQYysAyXPrdYzYZe0o2En6jjxmb6jJC1lOVmBhKTl5s0etD68xwtSt/V1dCIm/ 0IOw== 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=b0bDp5njIHs1/wg30R0FPPnh1K5cPUCWiBygXlXDWPQ=; b=Yt0OWbJp5F4NxJlUzba8YNToHAVvozcPafbIrYrDHJa2RBKJKUhZF1Rv8JZcjEDd9a htJged3XvO/kCRo7HlMJBXs0HODOBppfFX6i1P2mQxxduafeOQD8WTBlP+M0sA9eruZs 7HwKmfGrjkk7AkkidyTYO13aUlvp5muqFWmzfz2OLliHfxVdQnRuKKRKAmIrVQWkh0Y8 x3jg6sYHcEkilIxniPniVEd36y/fc0PhdST1zGRYqY258Q9ODERFhXM0WI9j6iwiDQ/b Eic3Q2chqe/Rls02iQ1MSWngURmoJMps+ue+y7uQM7PfZoxrt+9LTY6UAERs52CKVyiW 8smw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sJujmUZ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h9si11774657ejy.326.2020.08.17.15.45.40; Mon, 17 Aug 2020 15:46:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sJujmUZ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729872AbgHQTXA (ORCPT + 99 others); Mon, 17 Aug 2020 15:23:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:42292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730463AbgHQPf2 (ORCPT ); Mon, 17 Aug 2020 11:35:28 -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 3339222CB3; Mon, 17 Aug 2020 15:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678527; bh=QJSqNjTAX0hTsR3b06q2F58h9qio6PJsjCB4toyVe2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sJujmUZ0T8Dnn5Hehog9c3z2r2Dee+Rvb0YPs4eov3E8Hi8kd5ePoz2yOB/W6e+LX PPswx+KEUQ5AnRoir+XybMqh3gVdW7Q0J8VoR63X25bGkPrUNrXRmdFcDfR6p+3HKM vFFfQ0yTqHU5AjZr1Rt0oYJnM6s3DaPq8HIjG0/I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Rafael P." , Dean Nelson , Xin Long , "David S. Miller" , Sasha Levin Subject: [PATCH 5.8 366/464] net: thunderx: use spin_lock_bh in nicvf_set_rx_mode_task() Date: Mon, 17 Aug 2020 17:15:19 +0200 Message-Id: <20200817143851.303486853@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@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: Xin Long [ Upstream commit bab9693a9a8c6dd19f670408ec1e78e12a320682 ] A dead lock was triggered on thunderx driver: CPU0 CPU1 ---- ---- [01] lock(&(&nic->rx_mode_wq_lock)->rlock); [11] lock(&(&mc->mca_lock)->rlock); [12] lock(&(&nic->rx_mode_wq_lock)->rlock); [02] lock(&(&mc->mca_lock)->rlock); The path for each is: [01] worker_thread() -> process_one_work() -> nicvf_set_rx_mode_task() [02] mld_ifc_timer_expire() [11] ipv6_add_dev() -> ipv6_dev_mc_inc() -> igmp6_group_added() -> [12] dev_mc_add() -> __dev_set_rx_mode() -> nicvf_set_rx_mode() To fix it, it needs to disable bh on [1], so that the timer on [2] wouldn't be triggered until rx_mode_wq_lock is released. So change to use spin_lock_bh() instead of spin_lock(). Thanks to Paolo for helping with this. v1->v2: - post to netdev. Reported-by: Rafael P. Tested-by: Dean Nelson Fixes: 469998c861fa ("net: thunderx: prevent concurrent data re-writing by nicvf_set_rx_mode") Signed-off-by: Xin Long Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c index 2ba0ce115e63a..a82c708a32278 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c @@ -2042,11 +2042,11 @@ static void nicvf_set_rx_mode_task(struct work_struct *work_arg) /* Save message data locally to prevent them from * being overwritten by next ndo_set_rx_mode call(). */ - spin_lock(&nic->rx_mode_wq_lock); + spin_lock_bh(&nic->rx_mode_wq_lock); mode = vf_work->mode; mc = vf_work->mc; vf_work->mc = NULL; - spin_unlock(&nic->rx_mode_wq_lock); + spin_unlock_bh(&nic->rx_mode_wq_lock); __nicvf_set_rx_mode_task(mode, mc, nic); } -- 2.25.1