From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=51.159.59.229 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796482549; b=QyBsh3VatR5rvnwu/cW4LwOzYeIOou3dc7nM9QlsXy+ucH09ZVzp3d6jJ7EBdxphbT+E esdIejmf3taGsEHb5j0Rr5i1VIMy6hh2J9oMYgd9IL1Kn24vm25y83c/rJ/j7V8QNZWbg aZBHDnr8UcTOHQIrKdPS6wVN1a51egD/MCQcsfY96MnFvv7TJe5/VKP/aXKLO2sunfZ9S 47plHF6gX2XqCjLIxhZikbcRWPF0JuDiHMHfIdokhr4U2bI3Ob+eSpaEZm4NhtdF1w6lm mpykPhqFS9NPSiCWKNqjRF5zeQuFgbYrTpaeEm9aeOYKzqEoDMbIknSf8V7GWIZH3Pw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796482549; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; bh=vt6wOAW6KXnc/ZGMEQchH2bcq2R/yj3whnxL93AbRws=; b=CLPN+4e4f14aSoIPmvTHzdQIXHo4nF+xXWf1Uz98XKXTgW1nCbY+5T/NQd/X6vdlPlOP 0fNVtlSMKE325pJZvNifnQCLGsuoCVyLyh2sE7NDD0yWJgEA5b7GWMuSk7iFzwDB7cdV2 jLuZP2BSDvCgMYoJ5nYhcTFH44rbCktR+wm0eTPucCVpFWT10fPooLh/fNeOroldoyF0f Nvjujw2Sgn2IHes2Q3BJBwJ8ykW3TMLtTZJ+R1NYATSW6xcVwMDJGVqGU2jaALMPNk0Lh I/Wk3/IUapB/iX8rG8GxCoTvHuPDcHKKfzHECxjYpmk9ZEwTvf26Sp0NXtBi7nqEBBw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=1wt.eu; spf=pass smtp.mailfrom=1wt.eu; dkim=pass header.d=1wt.eu header.i=@1wt.eu header.a=rsa-sha256 header.s=mail header.b=dW8Netag; arc=none smtp.remote-ip=51.159.59.229 Received: from mta1.formilux.org (mta1.formilux.org [51.159.59.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D57CA606A322 for ; Sat, 5 Dec 2026 14:55:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D57CA606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=1wt.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=1wt.eu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=1wt.eu header.i=@1wt.eu header.a=rsa-sha256 header.s=mail header.b=dW8Netag DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1wt.eu; s=mail; t=1796482546; bh=vt6wOAW6KXnc/ZGMEQchH2bcq2R/yj3whnxL93AbRws=; h=From:Message-ID:From; b=dW8NetaglL1ElVGbDPx68lcu6yuBwwLIt3frsaHLT7w8ElpSSj37t3XFiNXgzYJP/ EPX1vebUzXYtOG2KopMZiNOCCy4xkm9n36Nt6Bu0fRUq9B6AD2KbkoqxWn2QAbBgbB TBd+G5WoK4BdLmHLzUAenG0xoZiGt6rY4sEOz2KY= Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by mta1.formilux.org (Postfix) with ESMTP id CF5C8C000B; Sat, 05 Dec 2026 15:55:46 +0100 (CET) Date: Sat, 5 Dec 2026 15:55:46 +0100 From: Willy Tarreau To: Tanuj Sharma Cc: security@kernel.org, david@ixit.cz, stable@vger.kernel.org Subject: Re: [SECURITY] nfc: llcp: slab-out-of-bounds read in nfc_llcp_recv_dm() Message-ID: References: <20261204215253.33907-1-ertanuj96@gmail.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261204215253.33907-1-ertanuj96@gmail.com> Hello, On Sat, Dec 05, 2026 at 03:22:52AM +0530, Tanuj Sharma wrote: > Hi, > > I'm reporting a slab-out-of-bounds read in the NFC LLCP stack, > triggerable over NFC contactless without authentication. > > ## Bug > > In net/nfc/llcp_core.c, nfc_llcp_recv_dm() reads the DM reason code > from skb->data[2]: > > reason = skb->data[2]; > > However, the entry point __nfc_llcp_recv() only guarantees > LLCP_HEADER_SIZE (2) bytes via pskb_may_pull(skb, LLCP_HEADER_SIZE). > When a 2-byte LLCP PDU arrives with DM ptype, the read at offset 2 > is 1 byte past the guaranteed length, causing a slab-out-of-bounds > read. > > The same bug is also reachable through the AGF (Aggregated Frame) > code path at line 1499: a 2-byte sub-PDU within an AGF frame passes > the `pdu_len >= LLCP_HEADER_SIZE` check and is dispatched to > nfc_llcp_recv_dm(), triggering the same OOB read. > > ## Remote trigger > > An attacker with an NFC-capable device within contactless range > (~10 cm) can send a 2-byte LLCP PDU with DM ptype (or embed a > 2-byte DM sub-PDU inside an AGF frame). No authentication or > pairing is required -- this is reachable during the NFC-DEP/LLCP > link activation phase. > > ## Impact > > - 1-byte kernel heap information leak (slab-out-of-bounds read) > - Reachable over NFC contactless, pre-authentication > - The leaked reason byte influences socket state machine decisions > (LLCP_DM_NOBOUND/LLCP_DM_REJ path selection), potentially > causing unexpected socket state transitions > > ## Affected versions > > All kernels since commit 5c0560b7a5c6 ("NFC: Handle LLCP > Disconnected Mode frames"), 2012-06-26 -- approximately 14 years. > Confirmed still vulnerable in mainline v7.4-rc5. > > ## KASAN proof > > Tested on both x86_64 (kernel 7.3.6) and aarch64 (kernel 7.4-rc5) > with CONFIG_KASAN_GENERIC=y, CONFIG_KASAN_INLINE=y: > > BUG: KASAN: slab-out-of-bounds in trigger_llcp_dm_oob+0x1bc/0x220 [nfc_llcp_dm_oob_poc] > Read of size 1 at addr ffff0000ce959442 by task insmod/1814 > > Allocated by task 1814: > [stack trace showing 2-byte allocation (kmalloc-8)] > > The PoC allocates a 2-byte buffer simulating a DM PDU with only the > LLCP header (ptype=DM, no reason byte), then reads buf[2]. KASAN > reports a 1-byte read past the allocation. > > ## Fix > > Add a length check requiring LLCP_HEADER_SIZE + 1 (3) bytes at the > top of nfc_llcp_recv_dm(), before accessing the reason field: > > --- > net/nfc/llcp_core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c > index XXXXXXX..XXXXXXX 100644 > --- a/net/nfc/llcp_core.c > +++ b/net/nfc/llcp_core.c > @@ -1283,6 +1283,9 @@ static void nfc_llcp_recv_dm(struct nfc_llcp_local *local, > u8 dsap, ssap, reason; > bool connecting = false; > > + if (skb->len < LLCP_HEADER_SIZE + 1) > + return; > + > dsap = nfc_llcp_dsap(skb); > ssap = nfc_llcp_ssap(skb); > reason = skb->data[2]; > -- > 2.43.0 > > Fixes: 5c0560b7a5c6 ("NFC: Handle LLCP Disconnected Mode frames") > Cc: stable@vger.kernel.org Please have a look at Documentation/process/submitting-patches.rst. It explains what's needed in a patch. Above, yours is almost correct (in the form, I'm not judging the contents not being a subsystem maintainer), but it lacks a subject, a description and a signed-off-by, so a maintainer will have to either spend time composing something from your description and commit it themself, marking you only as reported-by, or ask you to resubmit. Please always provide a patch in an applicable form (the output of git format-patch), making sure it passes checkpatch.pl. This will save some maintainers time and is the best way to see your work credited. Thanks, Willy