From: Simon Horman <horms@kernel.org>
To: Pavel Sakharov <p.sakharov@ispras.ru>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
Jose Abreu <joabreu@synopsys.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
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 <khoroshilov@ispras.ru>
Subject: Re: [PATCH] stmmac: Fix incorrect dereference in stmmac_*_interrupt()
Date: Tue, 6 Feb 2024 15:07:04 +0000 [thread overview]
Message-ID: <20240206150704.GD1104779@kernel.org> (raw)
In-Reply-To: <20240203150323.1041736-1-p.sakharov@ispras.ru>
On Sat, Feb 03, 2024 at 06:03:21PM +0300, Pavel Sakharov wrote:
> If 'dev' is NULL, the 'priv' variable has an incorrect address when
> dereferencing calling netdev_err().
>
> Pass 'dev' instead of 'priv->dev" to the function.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Pavel Sakharov <p.sakharov@ispras.ru>
Thanks Pavel,
I agree with your analysis that this can result in a NULL dereference.
And that your proposed fix is good: netdev_err() can handle a NULL
dev argument.
As this seems to be a fix I suggest it should be for net.
And that it should be based on that tree and designated as such
in the subject:
Subject: [PATCH net] ...
Also if it is a fix, it should have a fixes tag.
Perhaps this one:
Fixes: 8532f613bc78 ("net: stmmac: introduce MSI Interrupt routines for mac, safety, RX & TX")
I don't think there is a need to respin for the above, though please
keep this in mind when posting Networking patches in future.
Looking at the patch above, and stmmac_main.c, it seems that the following
functions also suffer from a similar problem:
static irqreturn_t stmmac_msi_intr_tx(int irq, void *data)
{
struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)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__);
...
And stmmac_msi_intr_rx(), which follows a similar pattern
to stmmac_msi_intr_tx().
I also note that in those functions "invalid dev pointer" seems misleading,
perhaps it ought to be "invalid queue" pointer.
As these problems seem to all have been introduced at the same time,
perhaps it is appropriate to fix them all in one patch?
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 4727f7be4f86..5ab5148013cd 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -5848,7 +5848,7 @@ static irqreturn_t stmmac_mac_interrupt(int irq, void *dev_id)
> struct stmmac_priv *priv = netdev_priv(dev);
>
> if (unlikely(!dev)) {
> - netdev_err(priv->dev, "%s: invalid dev pointer\n", __func__);
> + netdev_err(dev, "%s: invalid dev pointer\n", __func__);
> return IRQ_NONE;
> }
>
> @@ -5868,7 +5868,7 @@ static irqreturn_t stmmac_safety_interrupt(int irq, void *dev_id)
> struct stmmac_priv *priv = netdev_priv(dev);
>
> if (unlikely(!dev)) {
> - netdev_err(priv->dev, "%s: invalid dev pointer\n", __func__);
> + netdev_err(dev, "%s: invalid dev pointer\n", __func__);
> return IRQ_NONE;
> }
>
>
next prev parent reply other threads:[~2024-02-06 15:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-03 15:03 [PATCH] stmmac: Fix incorrect dereference in stmmac_*_interrupt() Pavel Sakharov
2024-02-06 15:07 ` Simon Horman [this message]
2024-02-07 11:34 ` Serge Semin
2024-02-14 9:27 ` [PATCH net v2] net: stmmac: Fix incorrect dereference in interrupt handlers Pavel Sakharov
2024-02-16 18:39 ` Serge Semin
2024-02-17 18:50 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240206150704.GD1104779@kernel.org \
--to=horms@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=joabreu@synopsys.com \
--cc=khoroshilov@ispras.ru \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=lvc-project@linuxtesting.org \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=p.sakharov@ispras.ru \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).