From: Piyus Kedia <piyus@iiitd.ac.in>
To: David Heidelberg <david@ixit.cz>, netdev@vger.kernel.org
Cc: oe-linux-nfc@lists.linux.dev, linux-kernel@vger.kernel.org,
Kapil Vaswani <kapil@presceralabs.ai>,
Piyus Kedia <piyus@iiitd.ac.in>
Subject: [PATCH net 1/3] net/nfc: llcp: fix the 16-bit truncation that overruns the SNL response skb
Date: Mon, 23 Nov 2026 08:05:48 +0530 [thread overview]
Message-ID: <20261123023548.3351531-2-piyus@iiitd.ac.in> (raw)
In-Reply-To: <20261123023548.3351531-1-piyus@iiitd.ac.in>
nfc_llcp_allocate_snl() accumulates the allocation size in a u16 while the
length it is given is a size_t:
u16 size = 0;
...
size += tlv_length;
skb = alloc_skb(size, GFP_KERNEL);
nfc_llcp_recv_snl() builds one SDRES TLV for every SDREQ TLV of a received
SNL PDU and passes the total as tlv_length. Each inbound SDREQ costs three
bytes - type, length, tid - and each SDRES it produces is four, so the
total
is four thirds of the PDU and about 48 KiB of SDREQs drives it past 65535.
The sum then wraps, alloc_skb() reserves a fraction of what is needed, and
nfc_llcp_send_snl_sdres() puts every entry of the list into it anyway:
hlist_for_each_entry_safe(sdp, n, tlv_list, node) {
skb_put_data(skb, sdp->tlv, sdp->tlv_len);
skb_put() runs out of tailroom and trips skb_over_panic(). With 16400
SDREQs the accumulated length is 65600, which truncates to 64:
skbuff: skb_over_panic: text:... len:382 put:4 head:... data:... tail:0
kernel BUG at net/core/skbuff.c:215!
RIP: 0010:skb_over_panic+0xcd/0xd0
skb_put
skb_put_data
nfc_llcp_send_snl_sdres
nfc_llcp_recv_snl
nfc_llcp_rx_skb
nfc_llcp_rx_work
process_scheduled_works
Hold the size in a size_t so the value that reaches alloc_skb() is the one
the caller computed. A request that large may now fail the allocation
instead, which the existing IS_ERR() path in both callers already handles.
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.
Signed-off-by: Kapil Vaswani <kapil@presceralabs.ai>
Signed-off-by: Piyus Kedia <piyus@iiitd.ac.in>
---
net/nfc/llcp_commands.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/nfc/llcp_commands.c b/net/nfc/llcp_commands.c
index 80a00938c..0a3d66e6c 100644
--- a/net/nfc/llcp_commands.c
+++ b/net/nfc/llcp_commands.c
@@ -542,7 +542,7 @@ static struct sk_buff *nfc_llcp_allocate_snl(struct nfc_llcp_local *local,
{
struct sk_buff *skb;
struct nfc_dev *dev;
- u16 size = 0;
+ size_t size = 0;
if (local == NULL)
return ERR_PTR(-ENODEV);
--
2.34.1
next prev parent reply other threads:[~2026-11-23 2:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 2:35 [BUG] net/nfc: a 16-bit truncation in nfc_llcp_allocate_snl() overruns the SNL response skb and BUGs the kernel Piyus Kedia
2026-11-23 2:35 ` Piyus Kedia [this message]
2026-11-29 14:24 ` [PATCH net 1/3] net/nfc: llcp: fix the 16-bit truncation that overruns the SNL response skb willemb
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=20261123023548.3351531-2-piyus@iiitd.ac.in \
--to=piyus@iiitd.ac.in \
--cc=david@ixit.cz \
--cc=kapil@presceralabs.ai \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oe-linux-nfc@lists.linux.dev \
/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
all inboxes | Powered by JetHome®