From: Jijie Shao <shaojijie@huawei.com>
To: <xuanqiang.luo@linux.dev>, <netdev@vger.kernel.org>
Cc: <shaojijie@huawei.com>, Xuanqiang Luo <luoxuanqiang@kylinos.cn>,
Jian Shen <shenjian15@huawei.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH net v1 3/3] net: hibmcge: fix double-free of tx skb on DMA mapping failure
Date: Fri, 10 Jul 2026 18:15:12 +0800 [thread overview]
Message-ID: <540e21ae-1c10-4ef3-928f-edac329b62e8@huawei.com> (raw)
In-Reply-To: <20260710090527.58354-4-xuanqiang.luo@linux.dev>
on 2026/7/10 17:05, xuanqiang.luo@linux.dev wrote:
> From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
>
> If hbg_dma_map() fails, hbg_net_start_xmit() frees the skb, but buffer->skb
> is left pointing to it. ring->ntu is not advanced, so the buffer is not
> visible to the TX cleanup path.
>
> A subsequent transmit normally overwrites the buffer. However, if the
> interface is brought down first, hbg_ring_uninit() calls hbg_buffer_free().
> It sees the stale pointer, attempts to unmap the failed mapping, and frees
> the skb again.
>
> Clear buffer->skb before freeing the skb in the error path, preventing
> hbg_buffer_free() from treating it as an outstanding TX buffer.
>
> Fixes: 40735e7543f9 ("net: hibmcge: Implement .ndo_start_xmit function")
> Cc: stable@vger.kernel.org
> Assisted-by: Opencode:deepseek-v4-pro[1m]
> Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Thanks for fixing this. The patch looks good to me.
Reviewed-by: Jijie Shao <shaojijie@huawei.com>
> ---
> drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c b/drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c
> index 0ae3149946769..4382af937e2e7 100644
> --- a/drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c
> +++ b/drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c
> @@ -155,6 +155,7 @@ netdev_tx_t hbg_net_start_xmit(struct sk_buff *skb, struct net_device *netdev)
> buffer->skb = skb;
> buffer->skb_len = skb->len;
> if (unlikely(hbg_dma_map(buffer))) {
> + buffer->skb = NULL;
> dev_kfree_skb_any(skb);
> return NETDEV_TX_OK;
> }
prev parent reply other threads:[~2026-07-10 10:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 9:05 [PATCH net v1 0/3] net: fix stale TX skb pointers on DMA map failure xuanqiang.luo
2026-07-10 9:05 ` [PATCH net v1 1/3] bna: fix use-after-free on DMA mapping failure xuanqiang.luo
2026-07-10 9:05 ` [PATCH net v1 2/3] hinic3: " xuanqiang.luo
2026-07-10 9:05 ` [PATCH net v1 3/3] net: hibmcge: fix double-free of tx skb " xuanqiang.luo
2026-07-10 10:15 ` Jijie Shao [this message]
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=540e21ae-1c10-4ef3-928f-edac329b62e8@huawei.com \
--to=shaojijie@huawei.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luoxuanqiang@kylinos.cn \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shenjian15@huawei.com \
--cc=stable@vger.kernel.org \
--cc=xuanqiang.luo@linux.dev \
/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