]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: libwx: fix the using of Rx buffer DMA
authorJiawen Wu <jiawenwu@trustnetic.com>
Mon, 14 Jul 2025 02:47:54 +0000 (10:47 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 24 Jul 2025 06:53:14 +0000 (08:53 +0200)
commit 5fd77cc6bd9b368431a815a780e407b7781bcca0 upstream.

The wx_rx_buffer structure contained two DMA address fields: 'dma' and
'page_dma'. However, only 'page_dma' was actually initialized and used
to program the Rx descriptor. But 'dma' was uninitialized and used in
some paths.

This could lead to undefined behavior, including DMA errors or
use-after-free, if the uninitialized 'dma' was used. Althrough such
error has not yet occurred, it is worth fixing in the code.

Fixes: 3c47e8ae113a ("net: libwx: Support to receive packets in NAPI")
Cc: stable@vger.kernel.org
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250714024755.17512-3-jiawenwu@trustnetic.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/wangxun/libwx/wx_lib.c
drivers/net/ethernet/wangxun/libwx/wx_type.h

index d84a763d040aa67a2415c493533c8befc0dc9a33..b7bfd3a432a4975862441fd6b231ab13c32a9697 100644 (file)
@@ -307,7 +307,7 @@ static bool wx_alloc_mapped_page(struct wx_ring *rx_ring,
                return false;
        dma = page_pool_get_dma_addr(page);
 
-       bi->page_dma = dma;
+       bi->dma = dma;
        bi->page = page;
        bi->page_offset = 0;
 
@@ -344,7 +344,7 @@ void wx_alloc_rx_buffers(struct wx_ring *rx_ring, u16 cleaned_count)
                                                 DMA_FROM_DEVICE);
 
                rx_desc->read.pkt_addr =
-                       cpu_to_le64(bi->page_dma + bi->page_offset);
+                       cpu_to_le64(bi->dma + bi->page_offset);
 
                rx_desc++;
                bi++;
index 910ad59c98751e19195a00336625958d6f525687..0fef9dfdd9a6b7364488abef2191c671a4657f25 100644 (file)
@@ -755,7 +755,6 @@ struct wx_tx_buffer {
 struct wx_rx_buffer {
        struct sk_buff *skb;
        dma_addr_t dma;
-       dma_addr_t page_dma;
        struct page *page;
        unsigned int page_offset;
 };