🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24309

[PATCH net v2 3/3] net/nfc: nci: do not hand a NULL skb to the nfc core

#24309
From: Piyus Kedia
Date: Mon, 30 Nov 2026 01:22
83 lines
13329 bytes
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/20261123023446.3350387-1-piyus@iiitd.ac.in/
Signed-off-by: Kapil Vaswani <kapil@presceralabs.ai>
Signed-off-by: Piyus Kedia <piyus@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
Technical Details
Message-ID: <20261130012208.1962491-4-piyus@iiitd.ac.in>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373757-linux-kernel-netdev=dewy.ru
References: <20261130012208.1962491-1-piyus@iiitd.ac.in>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373757-linux-kernel-netdev=dewy.ru
From: piyus@iiitd.ac.in (Piyus Kedia)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2 3/3] net/nfc: nci: do not hand a NULL skb to the nfc core
Date: Mon, 30 Nov 2026 06:52:08 +0530
Organization: Usenet Network
Message-ID: <20261130012208.1962491-4-piyus@iiitd.ac.in>
References: <20261130012208.1962491-1-piyus@iiitd.ac.in>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="1302017"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:TVUMcg9WRt+laZH0mQ66WPk/jYc= sha256:ebWpa39Ymgt/axCHTpyoWxidcSesqQHykLh0pLW8exA= sha1:g0tFAyB/nkMP1RlcK7fJgvwyH3M= sha256:Tj2/bhph5AlTYe8SO4WhyHG9pIgz8SLcLBXVQRM1ygQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 341A2125FB8; Mon, 30 Nov 2026 04:22:57 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=iiitd.ac.in
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id c3i4nfXOYB2h; Mon, 30 Nov 2026 04:22:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373757-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=iiitd.ac.in
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 9480A125FB3; Mon, 30 Nov 2026 04:22:45 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id EB06D28A86; Mon, 30 Nov 2026 01:22:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796001748; b=1zWjYv7y+6X4/KRFIUCYyCETIKCfKgQrY4ziDwVusCKHhXY8PihwXGAflvvg635KW81m 3+O0HuNUhAf3ubnBgZMuXxRWrkSv+qb6Gyn/G7sKJzuJkuWk7m9dCpi03uACqNQCUNPH4 3zy4ON8L82/4m4T170ykyHhXK+zVp2Uzs8lt6vlSOnZvz8HVtXrjCyhmEAvMVeBqgbzrQ JTvCUcF/3OIZu1rFEJdYcG7mfDdX4FYsNZrOQOoK6KEm+rZ8zlI/VqpSlZeG+/6aDaB28 +Fsut57LJprbSzF9TXBIZG0gsyFK58VU3cPFfej0pw0bqHVCNSm1Xir5QPs0sjvd42A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796001748; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State: X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-Id: X-Mailer:In-Reply-To:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Transfer-Encoding; bh=+SN+OvbyoeT8Kw+1MqPcvg5pvFq/ygGLyHg5fuC7W48=; b=tQA8sAmU7I4brybE9wcvtYCHNhS/XFmY0j1QGX1QFB+7ORZy9zkJGezLgHvzSjsCGTvT SBhObZFDL56el0cWjW/N/ladks2SRzZT1wPbkE9jQhRHTu3LdmUCDzlOFsKOvVmUZyRmv /VJUAsHbHZU1GEUNin4QK1oMdZ8MkgNBBvhvGRUYwf5gW/XUUWmt5SNCIOksrMzdclw8q DsTQHG4PFO4DdapTBSnLyDFaHspfLK6hKRfKSw72lrrFdyzBWSjf/8T3qtY8iOQ5625Yg cR3zajocc4UAXz5t6NiDcPZTlFvflaJzvhn50Z24d0icZGxa6wNBVBMog39VpLfvs9w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=iiitd.ac.in header.i=@iiitd.ac.in header.a=rsa-sha256 header.s=google header.b=SeroesUV; dmarc=none header.from=iiitd.ac.in; spf=pass smtp.mailfrom=iiitd.ac.in; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B5C0606A336; Mon, 30 Nov 2026 01:22:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=iiitd.ac.in header.i=@iiitd.ac.in header.a=rsa-sha256 header.s=google header.b=SeroesUV
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.173
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796001747; b=FIuSWk31BYo4icpbuqYOyVISHUzJm29ffs22h2eYru9ZRh3kYE419xb0gLhkgCNvGYih SQdam3+5+c8wiYmrWfIBKWG2jtNKOS1g3UAkfkkRYPytgTs3xYJy2gXyntnlhlfI52+c6 /gyAj6Pr6uduxi9oCqKQHTrYcvMYfvF2mEIZDUGMThLmrX5+x+gbJyhsRtgpPDDAOi+VJ Ui0CsGib6tC74p4Lvz5M5UcABE+swYG9T9GKtTOYJuq9QV9XCIvU4a4YPkYqGuKP3TR1X LTvsfwrTtxKhb4olMDJimahPLg22MSe1EDoXLnE81mq9OgdzCg7ACfXsRMJVQBmeBzQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796001747; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=+SN+OvbyoeT8Kw+1MqPcvg5pvFq/ygGLyHg5fuC7W48=; b=cX+2c1rI21bJQP65hl5LHSAv9xkN7E4T59ZBjCiUTgRjvGpsGa9ZJ4ImLban3AbMM6LA wvZzTbjEN5l0JK/88OBQ7xMHQVH7sg9DbtykvJCR+9+i0EVmRJTdTWw3M+++HB+Iki/gU Ay54w0gUPNN9vX0bkY/nVsRnXnOdLHg/D3+yZGIFA/dA/MshrBoCfIE0HqLsOUVLpZo2Q lpGaXzNHbtcqdNKpxmmunuVgyIs0dg8/GayTYHUtQwIx+WyYTk7LNvb5/aRASXf2aHqiG svgDxMjxjUatj01X5ys4cmjfRP3XL1RvyOK8PR+oC1HeaQRE6ev+80WVYHJUTWvPrbA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=iiitd.ac.in; spf=pass smtp.mailfrom=iiitd.ac.in; dkim=pass header.d=iiitd.ac.in header.i=@iiitd.ac.in header.a=rsa-sha256 header.s=google header.b=SeroesUV; arc=none smtp.remote-ip=209.85.214.173
X-Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C149606A31C for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 01:22:27 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5C149606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iiitd.ac.in
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iiitd.ac.in
X-Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2e9ae391a05so66406155ad.1 for <netdev@vger.kernel.org>; Sun, 29 Nov 2026 17:22:27 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iiitd.ac.in; s=google; t=1796001747; x=1796606547; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+SN+OvbyoeT8Kw+1MqPcvg5pvFq/ygGLyHg5fuC7W48=; b=SeroesUVqCrA23SW4Brd6BQHI2qtk7wHEn7YI1jhyso5zYpEGE8xALR1qrr6XfLkca X1ULs61ZT9hZUG3L+NNgH9O3GPxZvCrz7kQLeiwIuv9hD0zmyFm6EvHiMyacDD7UjXp9 nudils7UOVOWCgRz8nqrulJff0a6jAyaioe5M=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796001747; x=1796606547; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=+SN+OvbyoeT8Kw+1MqPcvg5pvFq/ygGLyHg5fuC7W48=; b=2jRqk3o5ro7HxloOQAoe7Q9rcegBd+sK9UlwVA9eLY+zPZkvWvQjJnIdC4Hp4skA3j g48r/YnvLfPw5670mUxcveTDvRZ/yYFNSIOgbrmFupUnDAmtC7BiTT/1kep9k0ZzuuTo Xh6+52g4njnRVF/a7Aoofw3i1T16mFJdMmAAlL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o7lJxH4WLlQ7ZSe1JGDq86 F4hIDYygj/r7fTUmPjQZDo3jHiFxX2UPnPI+sX7ODEuVCm3a3918j8wtvWAofVlmP
X-Received: by 2002:a17:903:228b:b0:2e8:3a42:7edf with SMTP id d9443c01a7336-2f031e4847emr261947395ad.12.1796001746804; Sun, 29 Nov 2026 17:22:26 -0800 (PST)
X-Received: from iiitd-S2600STB.iiitd.edu.in ([103.25.231.160]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f0bc695f31sm98858205ad.49.2026.11.29.17.22.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 17:22:26 -0800 (PST)
X-Cc: oe-linux-nfc@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kapil Vaswani <kapil@presceralabs.ai>
X-Mailer: git-send-email 2.34.1
X-In-Reply-To: <20261130012208.1962491-1-piyus@iiitd.ac.in>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list