[PATCH] net/qlcnic: fix possible use-after-free bugs in qlcnic_alloc_rx_skb()

Subsystems: networking drivers, qlogic qlcnic (1/10)gb ethernet driver, the rest

STALE1121d

2 messages, 2 authors, 2023-09-15 · open the first message on its own page

[PATCH] net/qlcnic: fix possible use-after-free bugs in qlcnic_alloc_rx_skb()

From: Ma Ke <hidden>
Date: 2023-09-13 10:42:06

In qlcnic_alloc_rx_skb(), when dma_map_single() fails, skb is freed
immediately. And skb could be freed again. This issue could allow a
local attacker to crash the system due to a use-after-free flaw.

Signed-off-by: Ma Ke <redacted>
---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
index 41894d154013..6501aaf2b5ce 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
@@ -832,6 +832,7 @@ static int qlcnic_alloc_rx_skb(struct qlcnic_adapter *adapter,
 	if (dma_mapping_error(&pdev->dev, dma)) {
 		adapter->stats.rx_dma_map_error++;
 		dev_kfree_skb_any(skb);
+		skb = NULL;
 		return -ENOMEM;
 	}
 
-- 
2.37.2

Re: [PATCH] net/qlcnic: fix possible use-after-free bugs in qlcnic_alloc_rx_skb()

From: Simon Horman <horms@kernel.org>
Date: 2023-09-15 05:45:50

On Wed, Sep 13, 2023 at 06:41:19PM +0800, Ma Ke wrote:
quoted hunk
In qlcnic_alloc_rx_skb(), when dma_map_single() fails, skb is freed
immediately. And skb could be freed again. This issue could allow a
local attacker to crash the system due to a use-after-free flaw.

Signed-off-by: Ma Ke <redacted>
---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
index 41894d154013..6501aaf2b5ce 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
@@ -832,6 +832,7 @@ static int qlcnic_alloc_rx_skb(struct qlcnic_adapter *adapter,
 	if (dma_mapping_error(&pdev->dev, dma)) {
 		adapter->stats.rx_dma_map_error++;
 		dev_kfree_skb_any(skb);
+		skb = NULL;
 		return -ENOMEM;
Hi Ma Ke,

I am a unclear on how skb could be freed a second time.
skb is a local variable which goes out of scope when
the function returns.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help