Three independent bugs in the NFC receive paths: a 16-bit truncation that
overruns an skb and panics, a use-after-free on a received frame, and a
NULL skb handed to the nfc core. They touch three different files and have
three different causes, so they can be taken in any order; they are posted
as one series only because v1 went out as three numbered patches in three
threads, which is what the review objected to.
1/3 holds the SNL allocation size in a size_t instead of a u16, so a large
SDREQ burst cannot wrap it and make skb_put() trip skb_over_panic().
2/3 takes the skb reference before sock_queue_rcv_skb() publishes the frame
on the receive queue rather than after, and releases it on failure.
3/3 stops nci_add_rx_data_frag() forwarding a NULL skb to the nfc core
after it has freed it on the reassembly error path.
Each was reproduced on net.git main under KASAN, and the patched kernel is
clean on the same reproducer with ordinary NFC traffic unaffected. Found
by AI-driven fuzzing built on top of syzkaller; every analysis was then
checked by hand against the code, as each patch records. The reproducers
are not posted - they go to anyone who asks for them.
Changes in v2, all of them from Willem de Bruijn's review:
- a Fixes: tag on each patch. v1 had none because the clone we were
working from does not reach back that far; from a full one they are
1/3 e0ae7bac06cc - gave nfc_llcp_allocate_snl() a size_t length to
add into the u16 that was already there
2/3 1727cf937401 - put skb_get() after sock_queue_rcv_skb() in both
handlers
3/3 122c195872e9 - added the target-mode exit that forwards the skb.
The NULL itself dates to 2011, but until this commit the shared
exit path only reached nci_data_exchange_complete(), which
accepts one.
- this cover letter, and one series rather than three numbered threads
- the full get_maintainer.pl recipient list
- a Link: to each bug report in the commit message, instead of threading
the patch under the report with In-Reply-To
v1 of the three patches, each threaded under its own bug report:
https://lore.kernel.org/netdev/2026…@iiitd.ac.in/
https://lore.kernel.org/netdev/2026…@iiitd.ac.in/
https://lore.kernel.org/netdev/2026…@iiitd.ac.in/
The review:
https://lore.kernel.org/netdev/will…@google.com/
Piyus Kedia (3):
net/nfc: llcp: fix the 16-bit truncation that overruns the SNL
response skb
net/nfc: llcp: take the skb reference before queueing it to the socket
net/nfc: nci: do not hand a NULL skb to the nfc core
net/nfc/llcp_commands.c | 2 +-
net/nfc/llcp_core.c | 33 +++++++++++++++++++--------------
net/nfc/nci/data.c | 15 +++++++++++----
3 files changed, 31 insertions(+), 19 deletions(-)
base-commit: 9437ee8b6cf607e883b36e44bd755968daaebd48
--
2.34.1