From: Stefan Wahren <wahrenst@gmx.net>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Dan Carpenter <dan.carpenter@linaro.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Simon Horman <horms@kernel.org>
Subject: Re: [PATCH net] net: vertexcom: mse102x: Fix possible double free of TX skb
Date: Wed, 30 Oct 2024 00:06:46 +0100 [thread overview]
Message-ID: <ea4842c2-7c65-4d45-9964-1a1274d29ea4@gmx.net> (raw)
In-Reply-To: <20241029150137.20dc8aab@kernel.org>
Am 29.10.24 um 23:01 schrieb Jakub Kicinski:
> On Tue, 29 Oct 2024 22:15:15 +0100 Stefan Wahren wrote:
>>> Isn't it easier to change this function to free the copy rather than
>>> the original? That way the original will remain valid for the callers.
>> You mean something like this?
>>
>> diff --git a/drivers/net/ethernet/vertexcom/mse102x.c
>> b/drivers/net/ethernet/vertexcom/mse102x.c
>> index a04d4073def9..2c37957478fb 100644
>> --- a/drivers/net/ethernet/vertexcom/mse102x.c
>> +++ b/drivers/net/ethernet/vertexcom/mse102x.c
>> @@ -222,7 +222,7 @@ static int mse102x_tx_frame_spi(struct mse102x_net
>> *mse, struct sk_buff *txp,
>> struct mse102x_net_spi *mses = to_mse102x_spi(mse);
>> struct spi_transfer *xfer = &mses->spi_xfer;
>> struct spi_message *msg = &mses->spi_msg;
>> - struct sk_buff *tskb;
>> + struct sk_buff *tskb = NULL;
>> int ret;
>>
>> netif_dbg(mse, tx_queued, mse->ndev, "%s: skb %p, %d@%p\n",
>> @@ -235,7 +235,6 @@ static int mse102x_tx_frame_spi(struct mse102x_net
>> *mse, struct sk_buff *txp,
>> if (!tskb)
>> return -ENOMEM;
>>
>> - dev_kfree_skb(txp);
>> txp = tskb;
>> }
>>
>> @@ -257,6 +256,8 @@ static int mse102x_tx_frame_spi(struct mse102x_net
>> *mse, struct sk_buff *txp,
>> mse->stats.xfer_err++;
>> }
>>
>> + dev_kfree_skb(tskb);
>> +
>> return ret;
>> }
> Exactly, I think it would work and it feels simpler.
I didn't test it yet, i need access to evaluation board before. But this
change will behave differently regarding stats of tx_bytes [1]. The
first version will include the padding, while the second does not.
[1] -
https://elixir.bootlin.com/linux/v6.12-rc5/source/drivers/net/ethernet/vertexcom/mse102x.c#L445
next prev parent reply other threads:[~2024-10-29 23:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-22 15:52 Stefan Wahren
2024-10-24 9:49 ` Simon Horman
2024-10-29 19:10 ` Jakub Kicinski
2024-10-29 21:15 ` Stefan Wahren
2024-10-29 22:01 ` Jakub Kicinski
2024-10-29 23:06 ` Stefan Wahren [this message]
2024-10-30 0:36 ` Jakub Kicinski
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=ea4842c2-7c65-4d45-9964-1a1274d29ea4@gmx.net \
--to=wahrenst@gmx.net \
--cc=andrew+netdev@lunn.ch \
--cc=dan.carpenter@linaro.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®