From patchwork Wed Feb 14 09:27:17 2024
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pavel Sakharov
X-Patchwork-Id: 200876
Return-Path:
Delivered-To: ouuuleilei@gmail.com
Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id
dn10csp1091890dyb;
Wed, 14 Feb 2024 01:29:19 -0800 (PST)
X-Forwarded-Encrypted: i=3;
AJvYcCVmMImOI5B3wYJ+EKHnpd6nJ9ZxGHuETz469q+jYlMj91PLOyzhbtke6bVuWcwfLfcFDxExSZrfzau9V7Pyy5pk6Lu0cQ==
X-Google-Smtp-Source:
AGHT+IHjTPJ1JoiQBcFyw5E7iYRPKRwFIyvFLDE2SCuoQkrDvaAspzBSUYiIp64pXvjz7ooTaS8I
X-Received: by 2002:a81:4a41:0:b0:607:8d16:dec6 with SMTP id
x62-20020a814a41000000b006078d16dec6mr1753491ywa.51.1707902958636;
Wed, 14 Feb 2024 01:29:18 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1707902958; cv=pass;
d=google.com; s=arc-20160816;
b=CZEvDa0t7FX8wlRQ5U35f00WAF4qbhZ6haW5idimsLlqxSOTxJvw46PDG4TJaZRklP
uOPnc4rmcvjpUOQlI4Vx5HCe3k1lo4ycCwXtGnvHLwdQf1XlUu+byqoRa2zJlrVq1JTX
IFi7a+8E3JonF7/EK1/4kPqtYhlyeltx6PHG0dC8JgXmSKFe3SDSSqbIXjiR1kU8sNtF
MJ/Gz/wSWsk0ivUMh8/Ev/YmaI9+FoVqJmUgiVgjd4R1WMvtzEFR0QRAzWLM2zsug1NP
/3SpxuA1+5+utwU12JhuYZQfJLh2c7DyK/r6X13bCLDnCkd/TfMZH6doz8E+Gew+X5Ra
p/RQ==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20160816;
h=content-transfer-encoding:mime-version:list-unsubscribe
:list-subscribe:list-id:precedence:references:in-reply-to:message-id
:date:subject:cc:to:from:dkim-signature:dkim-filter;
bh=VPs3SFZb3IOFTfYaDQIVN+l4DqNHEqyJHkJJnFGGUPw=;
fh=TjB5lgx+XAT91SemEX188H9cLeOYf3Vs09tySXrV0SU=;
b=U+k92wTBWVcacwuxSzVAlUi5t80/OflEFfzYfl7ewNnPtVW/agK5iRrK0Jj2hvtUgI
Ns4pMDtJZ9swjz1+PNfB8s5VYgz32n6PBJNgBGdCm5t9aJtb+pFNsYg+tvOJEWodDTT9
m3OarpcwveP8VlBLY3gLgY+YhgLis0jt2ShHoHIhX0IPG7EHwCHO5UL1+2yrHPPx54/p
y75mae241Js1sBdy1oKT+2ipMno5zhEWm151/XfFH28rrZSWHeH0exyjkDeKfPDoTKHU
LWJpRVAvQ1EyOn0lke5wlTpdD6DqEMOuRLj+SSfeSsqfFO83DjLBi8TZnGlqwBHyrLJj
kr5g==;
dara=google.com
ARC-Authentication-Results: i=2; mx.google.com;
dkim=pass header.i=@ispras.ru header.s=default header.b=OF2YRymp;
arc=pass (i=1 spf=pass spfdomain=ispras.ru dkim=pass dkdomain=ispras.ru
dmarc=pass fromdomain=ispras.ru);
spf=pass (google.com: domain of
linux-kernel+bounces-64961-ouuuleilei=gmail.com@vger.kernel.org designates
147.75.199.223 as permitted sender)
smtp.mailfrom="linux-kernel+bounces-64961-ouuuleilei=gmail.com@vger.kernel.org";
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru
X-Forwarded-Encrypted: i=2;
AJvYcCWBOzPKumpHQWPx4XKehgAPG2bcx4m6YMdxZVlgHb8733DRGPXEAVDoO27xhb0d9+JMPAST3f3T57GICMgHUwMJb5lM2A==
Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223])
by mx.google.com with ESMTPS id
b16-20020a05620a04f000b007872d46dd1bsi523412qkh.220.2024.02.14.01.29.18
for
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 14 Feb 2024 01:29:18 -0800 (PST)
Received-SPF: pass (google.com: domain of
linux-kernel+bounces-64961-ouuuleilei=gmail.com@vger.kernel.org designates
147.75.199.223 as permitted sender) client-ip=147.75.199.223;
Authentication-Results: mx.google.com;
dkim=pass header.i=@ispras.ru header.s=default header.b=OF2YRymp;
arc=pass (i=1 spf=pass spfdomain=ispras.ru dkim=pass dkdomain=ispras.ru
dmarc=pass fromdomain=ispras.ru);
spf=pass (google.com: domain of
linux-kernel+bounces-64961-ouuuleilei=gmail.com@vger.kernel.org designates
147.75.199.223 as permitted sender)
smtp.mailfrom="linux-kernel+bounces-64961-ouuuleilei=gmail.com@vger.kernel.org";
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru
Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org
[52.25.139.140])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5EF301C21ED9
for ; Wed, 14 Feb 2024 09:29:18 +0000 (UTC)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id C05741759F;
Wed, 14 Feb 2024 09:28:31 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru
header.b="OF2YRymp"
Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84])
(using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35E3012B61;
Wed, 14 Feb 2024 09:28:24 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=none smtp.client-ip=83.149.199.84
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1707902908; cv=none;
b=bntmwhp5zppDUfocH2APDERAsD8nvHqrOlq8ou8JZHiPEYk67IUbnagjr6ipwwNptD+NQN2a02WR4Z5RXeTHc25K8AcWpbQmiCHLeiHPjztQub3LoZFzJIWlpJwzFj5cJl76kA/Db1aIABi8KYbhtxQl2qw4rsTm57fvSYTSNVg=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1707902908; c=relaxed/simple;
bh=Mb6YxOmtcJ8Ub0l9X+yNHlgp/DjEXeH/cebfjQyMkP4=;
h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
MIME-Version;
b=Jg/47PjiFi4Ux2hz614aYSIIboSM24547PBUzQjidMlxk4x7TuGSrG1k2Uf7HYNoCumPDUMK8VzPb/LY1FsaaENGdpFDhsnp8P6U0KDFEbXMA+06ZFnWjDlCrhbX0KuoI7sZVgeUzyJ46EjuMnDtvNWR3s92+25b6eKiI+ceyzA=
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass (p=none dis=none) header.from=ispras.ru;
spf=pass smtp.mailfrom=ispras.ru;
dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru
header.b=OF2YRymp; arc=none smtp.client-ip=83.149.199.84
Authentication-Results: smtp.subspace.kernel.org;
dmarc=pass (p=none dis=none) header.from=ispras.ru
Authentication-Results: smtp.subspace.kernel.org;
spf=pass smtp.mailfrom=ispras.ru
Received: from localhost.localdomain (unknown [85.89.126.105])
by mail.ispras.ru (Postfix) with ESMTPSA id 8ABD2407672A;
Wed, 14 Feb 2024 09:28:16 +0000 (UTC)
DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 8ABD2407672A
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru;
s=default; t=1707902896;
bh=VPs3SFZb3IOFTfYaDQIVN+l4DqNHEqyJHkJJnFGGUPw=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=OF2YRymp0cVZzJyXtUILvhN8lfre24hOBN/XyofoROp2Xf8dZ1rsPQzpGJzC3G+/F
vrJOG1GVAertAUUCgLBQ7g4AP/tNzenhe8wRW2CUofP51heor82z4gxWfQtjtj/NAc
tjELpTMuxUbB/2jjnOxi3D05OwdcWoxeK14c3R/k=
From: Pavel Sakharov
To: Simon Horman
Cc: Pavel Sakharov ,
Alexandre Torgue ,
Serge Semin ,
Jose Abreu ,
"David S. Miller" ,
Eric Dumazet ,
Jakub Kicinski ,
Paolo Abeni ,
Maxime Coquelin ,
netdev@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org,
Alexey Khoroshilov
Subject: [PATCH net v2] net: stmmac: Fix incorrect dereference in interrupt
handlers
Date: Wed, 14 Feb 2024 12:27:17 +0300
Message-ID: <20240214092718.331891-1-p.sakharov@ispras.ru>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <20240206150704.GD1104779@kernel.org>
References:
Precedence: bulk
X-Mailing-List: linux-kernel@vger.kernel.org
List-Id:
List-Subscribe:
List-Unsubscribe:
MIME-Version: 1.0
X-getmail-retrieved-from-mailbox: INBOX
X-GMAIL-THRID: 1790866053087474619
X-GMAIL-MSGID: 1790866053087474619
If 'dev' or 'data' is NULL, the 'priv' variable has an incorrect address
when dereferencing calling netdev_err().
Since we get as 'dev_id' or 'data' what was passed as the 'dev' argument
to request_irq() during interrupt initialization (that is, the net_device
and rx/tx queue pointers initialized at the time of the call) and since
there are usually no checks for the 'dev_id' argument in such handlers
in other drivers, remove these checks from the handlers in stmmac driver.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 8532f613bc78 ("net: stmmac: introduce MSI Interrupt routines for mac, safety, RX & TX")
Signed-off-by: Pavel Sakharov
Reviewed-by: Serge Semin
---
v2: Drop the second argument checks in the handlers as suggested by Serge Semin .
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 20 -------------------
1 file changed, 20 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 75d029704503..e80d77bd9f1f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -6059,11 +6059,6 @@ static irqreturn_t stmmac_mac_interrupt(int irq, void *dev_id)
struct net_device *dev = (struct net_device *)dev_id;
struct stmmac_priv *priv = netdev_priv(dev);
- if (unlikely(!dev)) {
- netdev_err(priv->dev, "%s: invalid dev pointer\n", __func__);
- return IRQ_NONE;
- }
-
/* Check if adapter is up */
if (test_bit(STMMAC_DOWN, &priv->state))
return IRQ_HANDLED;
@@ -6079,11 +6074,6 @@ static irqreturn_t stmmac_safety_interrupt(int irq, void *dev_id)
struct net_device *dev = (struct net_device *)dev_id;
struct stmmac_priv *priv = netdev_priv(dev);
- if (unlikely(!dev)) {
- netdev_err(priv->dev, "%s: invalid dev pointer\n", __func__);
- return IRQ_NONE;
- }
-
/* Check if adapter is up */
if (test_bit(STMMAC_DOWN, &priv->state))
return IRQ_HANDLED;
@@ -6105,11 +6095,6 @@ static irqreturn_t stmmac_msi_intr_tx(int irq, void *data)
dma_conf = container_of(tx_q, struct stmmac_dma_conf, tx_queue[chan]);
priv = container_of(dma_conf, struct stmmac_priv, dma_conf);
- if (unlikely(!data)) {
- netdev_err(priv->dev, "%s: invalid dev pointer\n", __func__);
- return IRQ_NONE;
- }
-
/* Check if adapter is up */
if (test_bit(STMMAC_DOWN, &priv->state))
return IRQ_HANDLED;
@@ -6136,11 +6121,6 @@ static irqreturn_t stmmac_msi_intr_rx(int irq, void *data)
dma_conf = container_of(rx_q, struct stmmac_dma_conf, rx_queue[chan]);
priv = container_of(dma_conf, struct stmmac_priv, dma_conf);
- if (unlikely(!data)) {
- netdev_err(priv->dev, "%s: invalid dev pointer\n", __func__);
- return IRQ_NONE;
- }
-
/* Check if adapter is up */
if (test_bit(STMMAC_DOWN, &priv->state))
return IRQ_HANDLED;