From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Sasha Levin <sashal@kernel.org>,
kernelxing@tencent.com, pabeni@redhat.com, kuniyu@google.com,
mhal@rbox.co, ebiggers@google.com, aleksander.lobakin@intel.com
Subject: [PATCH AUTOSEL 6.18-5.10] net: restore napi_consume_skb()'s NULL-handling
Date: Mon, 8 Dec 2025 19:15:24 -0500 [thread overview]
Message-ID: <20251209001610.611575-32-sashal@kernel.org> (raw)
In-Reply-To: <20251209001610.611575-1-sashal@kernel.org>
From: Jakub Kicinski <kuba@kernel.org>
[ Upstream commit 4c03592689bc19df9deda7a33d56c6ac0cec8651 ]
Commit e20dfbad8aab ("net: fix napi_consume_skb() with alien skbs")
added a skb->cpu check to napi_consume_skb(), before the point where
napi_consume_skb() validated skb is not NULL.
Add an explicit check to the early exit condition.
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
## Summary Analysis
### 1. COMMIT MESSAGE ANALYSIS
- **Purpose**: Fixes a regression introduced by commit e20dfbad8aab
- **Problem**: The prior commit added `skb->alloc_cpu` check *before*
the point where NULL was being handled
- **Keywords**: "restore" indicates fixing a regression; explicitly
references the bug-introducing commit
- **Tags**: Reviewed-by Eric Dumazet (top networking maintainer),
Signed-off-by Jakub Kicinski (net maintainer)
### 2. CODE CHANGE ANALYSIS
**Before the bug (e20dfbad8aab~1)**:
```c
void napi_consume_skb(struct sk_buff *skb, int budget)
{
if (unlikely(!budget)) {
dev_consume_skb_any(skb); // Safe with NULL
return;
}
if (!skb_unref(skb)) // skb_unref() handles NULL!
return;
...
```
**After e20dfbad8aab introduced the bug**:
```c
if (skb->alloc_cpu != smp_processor_id() ...) // CRASH if skb==NULL
```
**The fix adds `|| !skb`** to redirect NULL skbs to
`dev_consume_skb_any()` which safely handles NULL (verified via call
chain: `dev_consume_skb_any` → `dev_kfree_skb_any_reason` →
`sk_skb_reason_drop` → `skb_unref` which has explicit NULL check).
**Technical Mechanism**: The bug is a NULL pointer dereference. When
`budget != 0` and `skb == NULL`, the code would try to access
`skb->alloc_cpu`, causing a kernel oops/crash.
### 3. CLASSIFICATION
- **Type**: Regression fix for NULL pointer dereference
- **Severity**: HIGH - kernel crash/oops
- **Category**: Core networking bug fix (not device ID, quirk, or DT)
### 4. SCOPE AND RISK ASSESSMENT
- **Lines changed**: 1 (adds `|| !skb` to existing condition)
- **Files touched**: 1 (`net/core/skbuff.c`)
- **Complexity**: Trivial - single condition addition
- **Risk**: VERY LOW - adds defensive NULL check to existing early-exit
path
- **Subsystem**: Core networking (`napi_consume_skb` is used by many
drivers)
### 5. USER IMPACT
- **Affected users**: Anyone using networking with drivers that call
`napi_consume_skb(NULL, non_zero_budget)`
- **Severity if hit**: Kernel crash/oops
- **Scope**: Core networking path = HIGH impact potential
### 6. STABILITY INDICATORS
- Reviewed-by: Eric Dumazet (authoritative networking maintainer)
- Signed-off-by: Jakub Kicinski (net maintainer)
- Obviously correct fix (adding NULL check before dereference)
### 7. DEPENDENCY CHECK
- **Depends on**: Commit e20dfbad8aab must be present (the bug-
introducing commit)
- This fix should be backported to any stable tree that contains
e20dfbad8aab
### CONCLUSION
This is a textbook stable backport candidate:
1. ✅ **Obviously correct**: Adding NULL check before pointer dereference
2. ✅ **Fixes real bug**: NULL pointer dereference → kernel crash
3. ✅ **Important issue**: Kernel oops in core networking path
4. ✅ **Small and contained**: Single character addition (`|| !skb`)
5. ✅ **No new features**: Pure regression fix
6. ✅ **Expert reviewed**: Eric Dumazet and Jakub Kicinski (net
maintainers)
7. ✅ **Restores previous behavior**: Explicit goal stated in commit
message
The fix is minimal, surgical, and addresses a serious crash in core
networking code. The dependency on e20dfbad8aab is the only
consideration - this fix must accompany that commit in any stable tree.
**YES**
net/core/skbuff.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 6be01454f262a..9f9ea86620ace 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1458,7 +1458,7 @@ void napi_skb_free_stolen_head(struct sk_buff *skb)
void napi_consume_skb(struct sk_buff *skb, int budget)
{
/* Zero budget indicate non-NAPI context called us, like netpoll */
- if (unlikely(!budget)) {
+ if (unlikely(!budget || !skb)) {
dev_consume_skb_any(skb);
return;
}
--
2.51.0
next prev parent reply other threads:[~2025-12-09 0:17 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-09 0:14 [PATCH AUTOSEL 6.18-6.1] ksmbd: fix use-after-free in ksmbd_tree_connect_put under concurrency Sasha Levin
2025-12-09 0:14 ` [PATCH AUTOSEL 6.18-6.17] wifi: rtw89: use skb_dequeue() for queued ROC packets to prevent racing Sasha Levin
2025-12-09 0:14 ` [PATCH AUTOSEL 6.18-6.6] ipv6: clean up routes when manually removing address with a lifetime Sasha Levin
2025-12-09 0:14 ` [PATCH AUTOSEL 6.18-5.10] ext4: remove page offset calculation in ext4_block_zero_page_range() Sasha Levin
2025-12-09 0:14 ` [PATCH AUTOSEL 6.18-6.6] fs/ntfs3: fix KMSAN uninit-value in ni_create_attr_list Sasha Levin
2025-12-09 0:14 ` [PATCH AUTOSEL 6.18-6.6] btrfs: abort transaction on item count overflow in __push_leaf_left() Sasha Levin
2025-12-09 0:14 ` [PATCH AUTOSEL 6.18-6.1] smb/server: fix return value of smb2_ioctl() Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.1] gfs2: Fix use of bio_chain Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-5.10] Bluetooth: btusb: Add new VID/PID 13d3/3533 for RTL8821CE Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.12] wifi: mac80211: reset CRC valid after CSA Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.12] Bluetooth: btusb: Add new VID/PID 0x0489/0xE12F for RTL8852BE-VT Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-5.10] wifi: mt76: mmio_*_copy fix byte order and alignment Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-5.10] btrfs: scrub: always update btrfs_scrub_progress::last_physical Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.12] bpf: Skip bounds adjustment for conditional jumps on same scalar register Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.12] wifi: rtl8xxxu: Fix HT40 channel config for RTL8192CU, RTL8723AU Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.12] Bluetooth: btusb: MT7920: Add VID/PID 0489/e135 Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.12] Bluetooth: btusb: MT7922: Add VID/PID 0489/e170 Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.12] virtio_blk: NULL out vqs to avoid double free on failed resume Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.1] kbuild: Use objtree for module signing key path Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.17] btrfs: use kvcalloc for btrfs_bio::csum allocation Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.12] net: sched: Don't use WARN_ON_ONCE() for -ENOMEM in tcf_classify() Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-5.10] hfsplus: Verify inode mode when loading from disk Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.6] gfs2: fix remote evict for read-only filesystems Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-5.10] net: amd-xgbe: use EOPNOTSUPP instead of ENOTSUPP in xgbe_phy_mii_read_c45 Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-5.10] net: init shinfo->gso_segs from qdisc_pkt_len_init() Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.17] Bluetooth: btusb: add new custom firmwares Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-5.10] hfsplus: fix missing hfs_bnode_get() in __hfs_bnode_create Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.12] cxgb4: Rename sched_class to avoid type clash Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.12] net: mana: Drop TX skb on post_work_request failure and unmap resources Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-5.10] hfsplus: fix volume corruption issue for generic/070 Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.17] wifi: rtw89: rtw8852bu: Added dev id for ASUS AX57 NANO USB Wifi dongle Sasha Levin
2025-12-09 0:15 ` Sasha Levin [this message]
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-5.15] fs/ntfs3: Support timestamps prior to epoch Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.1] smb/server: fix return value of smb2_query_dir() Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.17] wifi: rtw88: Add BUFFALO WI-U3-866DHP to the USB ID list Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.6] Bluetooth: btusb: Add new VID/PID 2b89/6275 for RTL8761BUV Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.12] bpf: Disable file_alloc_security hook Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.1] wifi: rtw89: phy: fix out-of-bounds access in rtw89_phy_read_txpwr_limit() Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.6] ntfs: set dummy blocksize to read boot_block when mounting Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-5.10] hfsplus: fix volume corruption issue for generic/073 Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.12] wifi: mt76: mt792x: fix wifi init fail by setting MCU_RUNNING after CLC load Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.12] gfs2: Fix "gfs2: Switch to wait_event in gfs2_quotad" Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.6] ksmbd: vfs: fix race on m_flags in vfs_cache Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.1] wifi: rtw89: flush TX queue before deleting key Sasha Levin
2025-12-09 0:15 ` [PATCH AUTOSEL 6.18-6.12] ice: Allow 100M speed for E825C SGMII device Sasha Levin
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=20251209001610.611575-32-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=aleksander.lobakin@intel.com \
--cc=ebiggers@google.com \
--cc=edumazet@google.com \
--cc=kernelxing@tencent.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=mhal@rbox.co \
--cc=pabeni@redhat.com \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
/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