Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4414861pxa; Mon, 10 Aug 2020 08:33:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYBJ1Q4uxIKnPAaru4AkUZuEvcvG/sOgu4JQNfCyPCIwayN139ekeqBYRls/Cbu2F00qch X-Received: by 2002:a17:906:2681:: with SMTP id t1mr21515358ejc.350.1597073587467; Mon, 10 Aug 2020 08:33:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597073587; cv=none; d=google.com; s=arc-20160816; b=xu7dlsQDQUv4PL3n7LRNOtxJA8KaRM9XssllcBVUocSoU3HyNEqGMdyaR9J70Tsr4b vNt+bvShcPRZDL04aHW6tpN8a7IQy9Csw9OO9cdANpwhe2GNxuh7cQAA4e6l9XLKqQ6J c8BJCWp1xERGAlHz2KRc90vYBUaXufiMmf5A//xHhymoESqu8JX2azI3e/Tpgo6FoCGp FDqhbyeVhBdOhHoXUuqi7wO7wC1QyRb3jpr3wPBAgyw50mwt7eduWcgLxnXCo9B1Mz9L uEeBFnXJueimrExvgPHEvsAF/jpMzo88ZP1cGZ+sgWDWoSsmTB3rGr9bCsXn4ug+iCg8 WY9w== 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=zhcBlbtk94ZOvt76gFKUw7jd2HTa6+wI4iPfrkN/9m4=; b=VWUpo6tNunV+NIP2rK2RJDfI2PdFecVJSJ9B+m5DM7SvuySaLaWT8PIP5+xOy1IqZg b7HHxq+W7ucRUFghi9xV64wIm+CvycMDaa4I3GqvEzYryo7Dl21CkGhEXkBuY94PJ3JS tn300VctwpiSh8YN3COSYh+e3erEhy4TB+BUkShcyvSzNygrCQaIWLNV2ByG5IR960dX IsIK0tMVI1hPYgGu/0ew6Byt2AR+JRB98yMWtZM2XKRSxhUvo1GBecvDjpB8Oj//V0a5 gq6nZ2RsmSYh/TfbpgGueckLgzbPXsAf8RIeT9XrRStS6JLlniEEiWJDLYx1BEzKpoVJ dJHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0Eix6Mot; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm21si10257050edb.602.2020.08.10.08.32.44; Mon, 10 Aug 2020 08:33:07 -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=0Eix6Mot; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729116AbgHJPak (ORCPT + 99 others); Mon, 10 Aug 2020 11:30:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:37638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728318AbgHJPah (ORCPT ); Mon, 10 Aug 2020 11:30:37 -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 655DA20774; Mon, 10 Aug 2020 15:30:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597073436; bh=yCnOv7z6QR8V//pqvrVl+elidpg/YiHVrVZ9pqUErzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Eix6MotZRTq77L5XkIg+eDqmqRe63MhzXhclL4qi4X4zuon3BscF7ytxw35Te6q2 vPOEPqGLRPIaxyFyHiwbzKzBhepZ0+dveAdZh9YWrUSXtufKd9m4BRuAANNlzGIFzK OZCXQ11voLLBu2b6Jvo7gEmO5wIPWie0NFMnkFGk= 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" Subject: [PATCH 4.19 39/48] net: thunderx: use spin_lock_bh in nicvf_set_rx_mode_task() Date: Mon, 10 Aug 2020 17:22:01 +0200 Message-Id: <20200810151806.141225080@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810151804.199494191@linuxfoundation.org> References: <20200810151804.199494191@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: Greg Kroah-Hartman --- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c @@ -2015,11 +2015,11 @@ static void nicvf_set_rx_mode_task(struc /* 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); }