nci_add_rx_data_frag() frees the skb and clears the local pointer when it cannot make room for the data accumulated so far, then falls through to the exit path shared with the success case: if (skb_cow_head(skb, reassembly_len)) { pr_err("error adding room for accumulated rx data\n"); kfree_skb(skb); skb = NULL; ... err = -ENOMEM; goto exit; } ... exit: if (ndev->nfc_dev->rf_mode == NFC_RF_TARGET) { /* Data received in Target mode, forward to nfc core */ err = nfc_tm_data_received(ndev->nfc_dev, skb); In target mode that NULL reaches nfc_llcp_data_received(), whose own NULL test is on the LLCP local and not on the skb, and __nfc_llcp_recv() then dereferences it in pskb_may_pull(): BUG: KASAN: null-ptr-deref in nfc_llcp_data_received Read of size 4 at addr 0000000000000070 by task kworker/u8:0/13 skb_headlen pskb_may_pull_reason pskb_may_pull __nfc_llcp_recv nfc_llcp_data_received nfc_tm_data_received Test the skb before forwarding it. The other branch, nci_data_exchange_complete(), already accepts a NULL skb and reports the error to the pending data exchange, so only the target-mode call needs it - and returning early instead would leave that exchange uncompleted. A peer reaches the failing branch by growing the reassembly with PBF_CONT fragments until the GFP_ATOMIC head expansion for the accumulated length cannot be satisfied. How this was found: by AI-driven fuzzing built on top of syzkaller. Its analysis was then checked by hand against the code, the fault was reproduced on net.git main under KASAN, and the patched kernel is clean on the same reproducer with ordinary NFC LLCP traffic unaffected. Fixes: 122c195872e9 ("NFC: NCI: Forward data received in Target mode to nfc core") Link: https://lore.kernel.org/netdev/2026…@iiitd.ac.in/ Signed-off-by: Kapil Vaswani <kap…@presceralabs.ai> Signed-off-by: Piyus Kedia <piy…@iiitd.ac.in> --- net/nfc/nci/data.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/net/nfc/nci/data.c b/net/nfc/nci/data.c index 4253edea5c8d..d7597fbd2a64 100644 --- a/net/nfc/nci/data.c +++ b/net/nfc/nci/data.c @@ -258,10 +258,17 @@ static void nci_add_rx_data_frag(struct nci_dev *ndev, exit: if (ndev->nfc_dev->rf_mode == NFC_RF_TARGET) { - /* Data received in Target mode, forward to nfc core */ - err = nfc_tm_data_received(ndev->nfc_dev, skb); - if (err) - pr_err("unable to handle received data\n"); + /* + * Data received in Target mode, forward to nfc core. skb is + * NULL when the reassembly above could not make room for the + * accumulated data; there is nothing left to forward and the + * core would dereference it. + */ + if (skb) { + err = nfc_tm_data_received(ndev->nfc_dev, skb); + if (err) + pr_err("unable to handle received data\n"); + } } else { nci_data_exchange_complete(ndev, skb, conn_id, err); }
-- 2.34.1