Re: [PATCH net 1/3] net/nfc: llcp: fix the 16-bit truncation that overruns the SNL response skb
From: willemb
Date: Sun Nov 29 2026 - 09:24:37 EST
Piyus Kedia wrote:
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@xxxxxxxxxxxxxxx>
Signed-off-by: Piyus Kedia <piyus@xxxxxxxxxxx>
For all three patches in this series:
https://patchwork.kernel.org/project/netdevbpf/list/?series=1219102
Patches targeting net must include valid Fixes tags; please add Fixes tags to all three patches, include a cover letter for the series, and CC the maintainers listed by get_maintainer.pl before respinning.
Also do not play games with the In-Reply-To. Use a Closes: (or Link:) tag to point back to bug reports.