Skip to contentSkip to conversation

qede: Fix NULL pointer dereference in TPA fragment processing

PATCH Applied Vaibhav Nagare 2 participants 2 messages Aug 18 – Aug 22

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 qede: Fix NULL pointer dereference in TPA fragment processing

Under memory pressure, the qede driver encounters NULL pointer dereferences when processing TPA continuation fragments.

Commit 8a8633978b84 ("qede: Add build_skb() support.") accidentally dropped the assignment of tpa_info->buffer.data in qede_tpa_start().

When memory pressure causes an SKB allocation failure in qede_tpa_start(), the driver sets tpa_start_fail = true and attempts to recycle the physical page later in qede_tpa_end() via qede_reuse_page(). However, because buffer.data was left uninitialized (NULL), qede_reuse_page() pushes a "ghost" BD (valid DMA mapping but NULL data pointer) back into the active Rx ring.

The next time the hardware uses this ring slot, it passes a NULL page to qede_fill_frag_skb(), causing a kernel panic.

Example crash from production system:

 BUG: unable to handle kernel NULL pointer dereference at 0x8
 RIP: qede_fill_frag_skb+0x96/0x430 [qede]
 Call Trace:
   qede_rx_int+0xb06/0x1de0
   qede_poll+0x2f4/0x6c0
   __napi_poll+0x2d/0x130

Fix the root cause by restoring the tpa_info->buffer.data assignment in qede_tpa_start(), ensuring valid pages are correctly tracked and recycled. Additionally, update the stale comment for struct qede_agg_info::buffer to reflect its current usage.

Fixes 8a8633978b84 ("qede: Add build_skb() support.")

---
v5: Addressed AI review feedback from Jakub Kicinski:
- Dropped redundant fast-path hardening code (NULL checks, early exits, and consume/recycle loop logic) as the root cause fix makes ghost BDs mathematically unreachable.
- Updated stale struct qede_agg_info::buffer comment in qede.h to reflect its current non-preallocated usage.
- Corrected commit title formatting in Fixes: tag.
v4: Fix err: label handling as identified by Jakub Kicinski:
- Restored tpa_info->buffer.data assignment in qede_tpa_start().
- Reverted err: label in qede_tpa_end() to use tpa_start_fail flag.
v3: Addressed AI review feedback:
- Fixed NULL pointer recycling and array bounds check order.
v2: Addressed AI review feedback from Simon Horman:
- Added net_ratelimit() and fixed NULL buffer recycling.
v1: https://lore.kernel.org/netdev/[email protected]/

 drivers/net/ethernet/qlogic/qede/qede.h    | 8 ++++----
 drivers/net/ethernet/qlogic/qede/qede_fp.c | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/net/ethernet/qlogic/qede/qede.h +4 -4
index 042a75f34060..0e7a0c2c1765 100644
@@ -303,10 +303,10 @@ enum qede_agg_state {
 };
 
 struct qede_agg_info {
-	/* rx_buf is a data buffer that can be placed / consumed from rx bd
-	 * chain. It has two purposes: We will preallocate the data buffer
-	 * for each aggregation when we open the interface and will place this
-	 * buffer on the rx-bd-ring when we receive TPA_START. We don't want
+	/* buffer is used to retain the Rx consumer descriptor when a TPA
+	 * session starts. If the SKB allocation fails during TPA_START,
+	 * we use this saved buffer to safely recycle the physical page
+	 * back into the rx-bd-ring via qede_reuse_page(). We don't want
 	 * to be in a state where allocation fails, as we can't reuse the
 	 * consumer buffer in the rx-chain since FW may still be writing to it
 	 * (since header needs to be modified for TPA).
drivers/net/ethernet/qlogic/qede/qede_fp.c +1 -0
index 33e18bb69774..2d42e51ff992 100644
@@ -845,6 +845,7 @@ static void qede_tpa_start(struct qede_dev *edev,
 					      pad, false);
 	tpa_info->buffer.page_offset = sw_rx_data_cons->page_offset;
 	tpa_info->buffer.mapping = sw_rx_data_cons->mapping;
+	tpa_info->buffer.data = sw_rx_data_cons->data;
 
 	if (unlikely(!tpa_info->skb)) {
 		DP_NOTICE(edev, "Failed to allocate SKB for gro\n");
Signature · 1 line
2.54.0
#1 lore raw
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 6 lines · On Tue, 18 Aug 2026 13:03:09 +0530 you wrote:

Under memory pressure, the qede driver encounters NULL pointer dereferences when processing TPA continuation fragments.

Commit 8a8633978b84 ("qede: Add build_skb() support.") accidentally dropped the assignment of tpa_info->buffer.data in qede_tpa_start().

Quoted 8 lines

When memory pressure causes an SKB allocation failure in qede_tpa_start(), the driver sets tpa_start_fail = true and attempts to recycle the physical page later in qede_tpa_end() via qede_reuse_page(). However, because buffer.data was left uninitialized (NULL), qede_reuse_page() pushes a "ghost" BD (valid DMA mapping but NULL data pointer) back into the active Rx ring.

[...]

Here is the summary with links:
- [net,v5] qede: Fix NULL pointer dereference in TPA fragment processing

    https://git.kernel.org/netdev/net/c/06aa3d26327f

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html