* [PATCH] rtase: fix double free of multi-frag skb on DMA map failure
@ 2026-07-21 2:38 Yun Lu
2026-07-22 19:55 ` Jacob Keller
2026-07-23 17:25 ` Jakub Kicinski
0 siblings, 2 replies; 4+ messages in thread
From: Yun Lu @ 2026-07-21 2:38 UTC (permalink / raw)
To: justinlai0215, larry.chiu, andrew+netdev, davem, edumazet, kuba,
pabeni
Cc: netdev
From: Yun Lu <luyun@kylinos.cn>
In rtase_start_xmit(), when the head buffer DMA mapping fails after
rtase_xmit_frags() has mapped all fragments, the error path clears
the fragment descriptors with rtase_tx_clear_range(), which frees
the skb through the last-frag slot and accounts tx_dropped. Control
then falls through to the common error label, which frees the same
skb a second time and counts it again.
Return right after clearing the fragments when the skb owns frags;
the no-frag case still drops through and frees the head skb once.
Fixes: d6e882b89fdf ("rtase: Implement .ndo_start_xmit function")
Signed-off-by: Yun Lu <luyun@kylinos.cn>
---
drivers/net/ethernet/realtek/rtase/rtase_main.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
index 255667775f0e..67f7fdada119 100644
--- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
+++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
@@ -1426,6 +1426,9 @@ static netdev_tx_t rtase_start_xmit(struct sk_buff *skb,
err_dma_1:
ring->skbuff[entry] = NULL;
rtase_tx_clear_range(ring, ring->cur_idx + 1, frags);
+ if (frags)
+ /* the frags were cleared above, along with the skb */
+ return NETDEV_TX_OK;
err_dma_0:
tp->stats.tx_dropped++;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] rtase: fix double free of multi-frag skb on DMA map failure
2026-07-21 2:38 [PATCH] rtase: fix double free of multi-frag skb on DMA map failure Yun Lu
@ 2026-07-22 19:55 ` Jacob Keller
2026-07-23 17:25 ` Jakub Kicinski
1 sibling, 0 replies; 4+ messages in thread
From: Jacob Keller @ 2026-07-22 19:55 UTC (permalink / raw)
To: Yun Lu, justinlai0215, larry.chiu, andrew+netdev, davem, edumazet,
kuba, pabeni
Cc: netdev
On 7/20/2026 7:38 PM, Yun Lu wrote:
> From: Yun Lu <luyun@kylinos.cn>
>
> In rtase_start_xmit(), when the head buffer DMA mapping fails after
> rtase_xmit_frags() has mapped all fragments, the error path clears
> the fragment descriptors with rtase_tx_clear_range(), which frees
> the skb through the last-frag slot and accounts tx_dropped. Control
> then falls through to the common error label, which frees the same
> skb a second time and counts it again.
>
> Return right after clearing the fragments when the skb owns frags;
> the no-frag case still drops through and frees the head skb once.
>
> Fixes: d6e882b89fdf ("rtase: Implement .ndo_start_xmit function")
> Signed-off-by: Yun Lu <luyun@kylinos.cn>
> ---
> drivers/net/ethernet/realtek/rtase/rtase_main.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> index 255667775f0e..67f7fdada119 100644
> --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> @@ -1426,6 +1426,9 @@ static netdev_tx_t rtase_start_xmit(struct sk_buff *skb,
> err_dma_1:
> ring->skbuff[entry] = NULL;
> rtase_tx_clear_range(ring, ring->cur_idx + 1, frags);
> + if (frags)
> + /* the frags were cleared above, along with the skb */
> + return NETDEV_TX_OK;
>
This feels a bit strange, but it matches the code in
rtase_tx_clear_range. I do find it a bit odd we're checking frags here
even though they got freed.. but it does seem to check out with how the
rtase_tx_clear_range() works.
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> err_dma_0:
> tp->stats.tx_dropped++;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rtase: fix double free of multi-frag skb on DMA map failure
2026-07-21 2:38 [PATCH] rtase: fix double free of multi-frag skb on DMA map failure Yun Lu
2026-07-22 19:55 ` Jacob Keller
@ 2026-07-23 17:25 ` Jakub Kicinski
2026-07-27 9:49 ` Justin Lai
1 sibling, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2026-07-23 17:25 UTC (permalink / raw)
To: justinlai0215
Cc: Yun Lu, larry.chiu, andrew+netdev, davem, edumazet, pabeni,
netdev
On Tue, 21 Jul 2026 10:38:36 +0800 Yun Lu wrote:
> From: Yun Lu <luyun@kylinos.cn>
>
> In rtase_start_xmit(), when the head buffer DMA mapping fails after
> rtase_xmit_frags() has mapped all fragments, the error path clears
> the fragment descriptors with rtase_tx_clear_range(), which frees
> the skb through the last-frag slot and accounts tx_dropped. Control
> then falls through to the common error label, which frees the same
> skb a second time and counts it again.
>
> Return right after clearing the fragments when the skb owns frags;
> the no-frag case still drops through and frees the head skb once.
>
> Fixes: d6e882b89fdf ("rtase: Implement .ndo_start_xmit function")
> Signed-off-by: Yun Lu <luyun@kylinos.cn>
Justin, please review.
> diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> index 255667775f0e..67f7fdada119 100644
> --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> @@ -1426,6 +1426,9 @@ static netdev_tx_t rtase_start_xmit(struct sk_buff *skb,
> err_dma_1:
> ring->skbuff[entry] = NULL;
> rtase_tx_clear_range(ring, ring->cur_idx + 1, frags);
> + if (frags)
> + /* the frags were cleared above, along with the skb */
> + return NETDEV_TX_OK;
>
> err_dma_0:
> tp->stats.tx_dropped++;
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] rtase: fix double free of multi-frag skb on DMA map failure
2026-07-23 17:25 ` Jakub Kicinski
@ 2026-07-27 9:49 ` Justin Lai
0 siblings, 0 replies; 4+ messages in thread
From: Justin Lai @ 2026-07-27 9:49 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Yun Lu, Larry Chiu, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org
Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Tue, 21 Jul 2026 10:38:36 +0800 Yun Lu wrote:
> > From: Yun Lu <luyun@kylinos.cn>
> >
> > In rtase_start_xmit(), when the head buffer DMA mapping fails after
> > rtase_xmit_frags() has mapped all fragments, the error path clears the
> > fragment descriptors with rtase_tx_clear_range(), which frees the skb
> > through the last-frag slot and accounts tx_dropped. Control then falls
> > through to the common error label, which frees the same skb a second
> > time and counts it again.
> >
> > Return right after clearing the fragments when the skb owns frags; the
> > no-frag case still drops through and frees the head skb once.
> >
> > Fixes: d6e882b89fdf ("rtase: Implement .ndo_start_xmit function")
> > Signed-off-by: Yun Lu <luyun@kylinos.cn>
>
> Justin, please review.
>
> > diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > index 255667775f0e..67f7fdada119 100644
> > --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > @@ -1426,6 +1426,9 @@ static netdev_tx_t rtase_start_xmit(struct
> > sk_buff *skb,
> > err_dma_1:
> > ring->skbuff[entry] = NULL;
> > rtase_tx_clear_range(ring, ring->cur_idx + 1, frags);
> > + if (frags)
> > + /* the frags were cleared above, along with the skb */
> > + return NETDEV_TX_OK;
> >
> > err_dma_0:
> > tp->stats.tx_dropped++;
Reviewed-by: Justin Lai <justinlai0215@realtek.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-27 9:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21 2:38 [PATCH] rtase: fix double free of multi-frag skb on DMA map failure Yun Lu
2026-07-22 19:55 ` Jacob Keller
2026-07-23 17:25 ` Jakub Kicinski
2026-07-27 9:49 ` Justin Lai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.