From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796001747; b=hwm7A4MYzhpDBhiBeGsftlsa7QOQTSj7H8sX/yZRvAL2UKZB4LZjiA6f/W4gGg8r+b/D 78IWGnWEqG5tri09AFHzeEgGhFL7Y3+uioOCy4+Ha96/FPQlibtiBMpEHsD8Gk1UpdLSm TubTrlAshU6k2hBNuB2Dv9oAs5Q4VAwkp0QlkBtAJfy/zV9RUFfmMriAFpP/wuuKYlozJ wUYh8PoewMrJSY0YqNC6Qnfb7eLqbTbYyNpTtPG534mVsu43H+a+pwr2wY18vAOF8x9V6 qqgojeX9FIQeKrjITii4EMQCcUNFFDYcI0kJePJNCfuoAadKYSfB6Va7EkFsvQv3WeA== 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=tlKnNGG8rzNPKUQt09ecb4DE90tgZBu9wt1acdgQaGFP21zIK0qNf8dmkm8NEIopQyVb QgdSB7o2b6493FL47EP/ks7yB3Pv0BtLaIDE997fhQa3gaSpuIqBGeOm1e6LIBgr/yflO VPd1pGf9e3B1VGlusFevxBtYddi4jvVWArWZHtSpvdBBGwmH6JNdx1CWxTWE0NO3wsptc I7DxKLF+FUyNZWV2edeGZK0NxBQ6M0qVNjqGsRUGXCNlNoXwlaWs+hnq9Ajc1hXKPI7tg 0GM1dIbdqzlt1epfNZ7vjtTmrdrfmXrYisTZcHkfZuQGSr6IFdEdb8q5lQZnHlAx/8A== 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.170 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 86D50606A32F for ; Mon, 30 Nov 2026 01:22:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 86D50606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iiitd.ac.in Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iiitd.ac.in 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 Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2f02b9c1f6fso66302215ad.0 for ; Sun, 29 Nov 2026 17:22:27 -0800 (PST) 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=dANKnTxiGWmsPKQxndTVfCP/MkacDcZVDKvRnxsyBlRDA/eR0wwAjOOAYBMHLUJA76 Sm/scyCf91XsECM0rAgDRp4bmbnWdEK5DqoI2e7HHd0Q5Bmqs7lU0XHLpPc5wZQEN7FA zzmGeY9q39bgZ60l0IPkrsWDN4RbSqj0seaBFXojWQoGBTIMLkvK/UAD5JKIdqnxXZgC b4wfusvAaV9vwY3z0TcTismTMBvlmD2NQcPNtMQabTFr8tg3PvqjSYZBcpA2tlo5abco McHTLqpUYqZVOvN+QDfSZKdPFQQDKVt1CfFkHOT5hYiZRfdX45tQcyxOKQ2Zvmjv4ec7 +FdA== X-Forwarded-Encrypted: i=1; AL+hErHHT9liMn7Xwa/XXhCgMjFjvWyRcrWhwHd3531/T/R64p195ie18PAup4/B7g8/FQN2iMxvc0E7PRmW5sw=@vger.kernel.org X-Gm-Message-State: APuU4Z+Ph7HRwzdGh0GcJGhdHmxgIooYQbWQ5UMGKoDhexFoUxV9u2EG VzNwYR1qxgxhSJ2YeK+aBH+wQidAGxDY5xppTMDnDXNTwU7Sa0jReKhZzHHmyRunuB4= X-Gm-Gg: AZFdTZfCcHw62DR43p9iu/uyNCPwYPiKBnHdnuzrfVhNtAdfVSvvrvDu6dyiR/u9t1C FYIao4nv43n4i4FhRraCHfd/+VMVgRaUrcra1hPaMaUFBiWHt835oNy88IH7sj5xo2BhjWZqNJB tB8nWGg/yS498fInCThSTjLTO5AqRiRQjevLZmlitOKqLsaB32LHw3bJrYo1PkKfCewOrmCFTEQ 2SiXvb6slxwKpaEU4emZ0DkME1wDGnOWvXELzhk2/PkGcH93Ih4zOkS8BLCjqMQ8JTUB0l/qLVY 73Nv2pYfy5ajsbFQmjvPiwpClbiPTQhetGf2CoN7bOVJcLGvZU4wZDDzO6VFtTJe2LO33ZQPIh0 m21evalkQt0dOT5NNceBKG2Hpnojzz+o2ZPy3baKQJ9sM3yDtF8DKiK9DkvaV8xXF/heqCe1/gn I4cNa9KWpRiS7O/bKMgxuh4z/uT1Zxfb2XzocD27jV8gq6zRvxNGLH5YSgOOFbTuMFcyD9khPzy nrWj5pM8olu1nssy+PNK6GJmH6rV2RWchfF5kmcbTknD8aVGawrxOZUlJwXTrYJ8ld3woSWHG+z F2phb0qq/5W2XDHITUYJSg4MdYI0L4IJYTuDrLohUbCoOA/wYfnh0qIOTa3DiyP7wOb7fUfv+mo o0hLej99D2gIG/hJu+s8ymkuFqiVbA1+Khy+4hKxwa8PcjTSCt17APSlrxBCHUFZI 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) 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) From: Piyus Kedia To: David Heidelberg , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman Cc: oe-linux-nfc@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kapil Vaswani 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 Message-Id: <20261130012208.1962491-4-piyus@iiitd.ac.in> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261130012208.1962491-1-piyus@iiitd.ac.in> References: <20261130012208.1962491-1-piyus@iiitd.ac.in> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Piyus Kedia --- 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