From: Aleksander Jan Bajkowski <olek2@wp.pl>
To: Florian Fainelli <f.fainelli@gmail.com>,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, jacob.e.keller@intel.com, andrew@lunn.ch,
horms@kernel.org, john@phrozen.org, ralph.hempel@lantiq.com,
ralf@linux-mips.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2 1/1] net: ethernet: lantiq_etop: fix memory disclosure
Date: Mon, 23 Sep 2024 23:08:15 +0200 [thread overview]
Message-ID: <991dc2b6-12ef-458d-b37f-562c15a73a07@wp.pl> (raw)
In-Reply-To: <0a9830fe-790d-4ccd-bec9-3fbb32f18aa8@gmail.com>
Hi Florian,
On 23.09.2024 20:21, Florian Fainelli wrote:
> On 9/21/24 03:58, Aleksander Jan Bajkowski wrote:
>> When applying padding, the buffer is not zeroed, which results in memory
>> disclosure. The mentioned data is observed on the wire. This patch uses
>> skb_put_padto() to pad Ethernet frames properly. The mentioned function
>> zeroes the expanded buffer.
>>
>> In case the packet cannot be padded it is silently dropped. Statistics
>> are also not incremented. This driver does not support statistics in the
>> old 32-bit format or the new 64-bit format. These will be added in the
>> future. In its current form, the patch should be easily backported to
>> stable versions.
>>
>> Ethernet MACs on Amazon-SE and Danube cannot do padding of the packets
>> in hardware, so software padding must be applied.
>>
>> Fixes: 504d4721ee8e ("MIPS: Lantiq: Add ethernet driver")
>> Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
>> ---
>> drivers/net/ethernet/lantiq_etop.c | 11 ++++++-----
>> 1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/lantiq_etop.c
>> b/drivers/net/ethernet/lantiq_etop.c
>> index 3c289bfe0a09..36f1e3c93ca5 100644
>> --- a/drivers/net/ethernet/lantiq_etop.c
>> +++ b/drivers/net/ethernet/lantiq_etop.c
>> @@ -477,11 +477,11 @@ ltq_etop_tx(struct sk_buff *skb, struct
>> net_device *dev)
>> struct ltq_etop_priv *priv = netdev_priv(dev);
>> struct ltq_etop_chan *ch = &priv->ch[(queue << 1) | 1];
>> struct ltq_dma_desc *desc = &ch->dma.desc_base[ch->dma.desc];
>> - int len;
>> unsigned long flags;
>> u32 byte_offset;
>> - len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len;
>> + if (skb_put_padto(skb, ETH_ZLEN))
>> + return NETDEV_TX_OK;
>
> You should consider continuing to use the temporary variable 'len'
> here, and just re-assign it after the call to skb_put_padto() and
> avoid introducing potential user-after-free near the point where you
> program the buffer length into the HW. This also minimizes the amount
> of lines to review.
To the best of my knowledge, the skb is not released until the DMA
finishes the transfer.
Then the ltq_etop_poll_tx() function is called, which releases the skb.
Can you explain
what sequence of events can lead to a use-after-free error?
-->ltq_etop_tx()
|
| (dma irq fires)
|
-->ltq_etop_dma_irq()
|
| (napi task schedule)
|
-->ltq_etop_poll_tx()
|
|
|
-->dev_kfree_skb_any()
Regards
next prev parent reply other threads:[~2024-09-23 21:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-21 10:58 [PATCH net v2 0/1] " Aleksander Jan Bajkowski
2024-09-21 10:58 ` [PATCH net v2 1/1] " Aleksander Jan Bajkowski
2024-09-23 18:21 ` Florian Fainelli
2024-09-23 21:08 ` Aleksander Jan Bajkowski [this message]
2024-09-23 21:13 ` Florian Fainelli
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=991dc2b6-12ef-458d-b37f-562c15a73a07@wp.pl \
--to=olek2@wp.pl \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=john@phrozen.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ralf@linux-mips.org \
--cc=ralph.hempel@lantiq.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
all inboxes | Powered by JetHome®