From patchwork Fri Jan 5 23:54:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13512622 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 071C8364B7 for ; Fri, 5 Jan 2024 23:55:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Xa+RmG7G" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-4287791e09dso690391cf.2 for ; Fri, 05 Jan 2024 15:55:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1704498901; x=1705103701; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=w7wIZBkXxLJs2TL6ymRxvLKL1OMePhdREdeAC7t5pzw=; b=Xa+RmG7GU0dqacSthvB2mVJ3nDnmEKbOsYmbEaCuaQlzp4Cieuw9FQW/1a4qY0hiFi 6Cqd7/3+CjtlbzY3ghp/cHMeY/IvfyKehN3M9OiAZRaPShAEZEBWOOYZSwhak8Bv/kmU fxzdniV7DaupKTYsK6pKf6dlonN0gMJ3An9Mc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704498901; x=1705103701; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=w7wIZBkXxLJs2TL6ymRxvLKL1OMePhdREdeAC7t5pzw=; b=lw1aSbndMszjjcet+BVp6kPKC8JqdtkgLnc9URDfucHklfxq1xtE09RvnqrLgYA6nK znoSgufwy6ZY1IUVcAuTDLZ95VyXH9lORVbvf0BFcllVXNu485b27WZEfwkiwTic4cIB MVpGXzj4Vv9UgloxsqEgIuH31GMSQil71Y25wcFN+2/ieOr8JOryRrlqxnlp0LgwWczI MkvTWEl5T6YTHeyJKL4TL15kykiiZZyA8UaFBlKYhPKR/j4r4z9vxyRAQnRG/IAOxpwQ U7tXlNtUYi7uUmHkfDhoCe2K0HZ2fd/WRjj8JFZlWCUuLBks734EjokoyOmiob6S+fyI 3zhQ== X-Gm-Message-State: AOJu0YzqW5+ViNQa2e2B1xzbceUOWafxmh8XYsW6vUeMhCQkiHypt4is bzA9r5xoXz2T1v37Bm/HyelKkjWER9Z+ X-Google-Smtp-Source: AGHT+IEiGPkgnm92SezssqFyKr5z6wdty1aRE6jzJG9u7tPvdugIj5mek1QTUY1YaMiAbf+IjbTuZQ== X-Received: by 2002:ac8:57ce:0:b0:429:7d6b:4ff with SMTP id w14-20020ac857ce000000b004297d6b04ffmr299409qta.80.1704498900834; Fri, 05 Jan 2024 15:55:00 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id fb27-20020a05622a481b00b00427f0fdcd44sm1185612qtb.1.2024.01.05.15.54.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2024 15:55:00 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, horms@kernel.org Subject: [PATCH net-next 3/3] bnxt_en: Fix RCU locking for ntuple filters in bnxt_rx_flow_steer() Date: Fri, 5 Jan 2024 15:54:39 -0800 Message-Id: <20240105235439.28282-4-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240105235439.28282-1-michael.chan@broadcom.com> References: <20240105235439.28282-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Similar to the previous patch, RCU locking was released too early in bnxt_rx_flow_steer(). Fix it to unlock after reading fltr->base.sw_id to guarantee that fltr won't be freed while we are still reading it. Fixes: cb5bdd292dc0 ("bnxt_en: Add bnxt_lookup_ntp_filter_from_idx() function") Reported-by: Simon Horman Link: https://lore.kernel.org/netdev/20231225165653.GH5962@kernel.org/ Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index fb5af8a34c8f..0aacd3c6ed5c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -14020,8 +14020,8 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, rcu_read_lock(); fltr = bnxt_lookup_ntp_filter_from_idx(bp, new_fltr, idx); if (fltr) { - rcu_read_unlock(); rc = fltr->base.sw_id; + rcu_read_unlock(); goto err_free; } rcu_read_unlock();