Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Piyus Kedia
Mon, 23 Nov 2026 02:35
[PATCH net 1/3] net/nfc: llcp: fix the 16-bit truncation that overruns the SNL response skb
Author: Piyus Kedia
Date: Mon, 23 Nov 2026 02:35
Date: Mon, 23 Nov 2026 02:35
66 lines
12941 bytes
12941 bytes
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
Re: [PATCH net 1/3] net/nfc: llcp: fix the 16-bit truncation that overruns the SNL response skb
Author: Piyus Kedia
Date: Mon, 30 Nov 2026 01:34
Date: Mon, 30 Nov 2026 01:34
38 lines
12239 bytes
12239 bytes
Hi Willem,
Thanks for the review, and sorry for the threading mess in v1.
v2 is posted as one series with a cover letter:
the series: https://lore.kernel.org/all/20261130012208.1962491-1-piyus@iiitd.ac.in/
1/3 the SNL allocation truncated to 16 bits:
https://lore.kernel.org/all/20261130012208.1962491-2-piyus@iiitd.ac.in/
2/3 the skb reference taken after the frame is queued:
https://lore.kernel.org/all/20261130012208.1962491-3-piyus@iiitd.ac.in/
3/3 the NULL skb forwarded to the nfc core:
https://lore.kernel.org/all/20261130012208.1962491-4-piyus@iiitd.ac.in/
All three patches now carry a Fixes: tag. v1 had none because the clone we
were working from does not reach back that far, which we should have said
instead of just leaving them off:
1/3 e0ae7bac06cc ("NFC: llcp: Service Name Lookup SDRES aggregation")
2/3 1727cf937401 ("NFC: llcp: Fix Rx memory leak")
3/3 122c195872e9 ("NFC: NCI: Forward data received in Target mode to nfc core")
The cover letter says why each of those is the commit that introduced the
bug rather than one that merely touched the line. 3/3 is the one worth a
second look: the NULL has been assigned since 2011, but until the
target-mode exit was added the shared exit path only reached
nci_data_exchange_complete(), which accepts a NULL skb.
The recipient list is now the full get_maintainer.pl output, and each patch
carries a Link: to its bug report in the commit message instead of being
threaded under it.
Thanks and regards,
Piyus Kedia
Kapil Vaswani
pw-bot: cr
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads