All of lore.kernel.org
 help / color / mirror / Atom feed
From: willemb@google.com
To: Piyus Kedia <piyus@iiitd.ac.in>, 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: Re: [PATCH net 1/3] net/nfc: llcp: fix the 16-bit truncation that overruns the SNL response skb
Date: Sun, 29 Nov 2026 09:24:26 -0500	[thread overview]
Message-ID: <willemb.360aecefa3166@google.com> (raw)
In-Reply-To: <20261123023548.3351531-2-piyus@iiitd.ac.in>

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@presceralabs.ai>
> Signed-off-by: Piyus Kedia <piyus@iiitd.ac.in>

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.

  reply	other threads:[~2026-11-29 14:24 UTC|newest]

Thread overview: 4+ 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 ` [PATCH net 1/3] net/nfc: llcp: fix the 16-bit truncation that overruns the SNL response skb Piyus Kedia
2026-11-29 14:24   ` willemb [this message]
2026-11-30  1:34     ` Piyus Kedia

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=willemb.360aecefa3166@google.com \
    --to=willemb@google.com \
    --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 \
    --cc=piyus@iiitd.ac.in \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.