Skip to content

nfc: fix skb leaks in LLC nop and in data exchange error paths

Joas Antonio dos Santos lkml netdev oe-linux-nfc 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3nfc: hci: free the skb sent through LLC nopnet/nfc/hci/llc_nop.c+10 -10 replies
2/3nfc: rawsock: free the response skb when the data exchange failsnet/nfc/rawsock.c+2 -20 replies
3/3nfc: llcp: free the response skb when the data exchange failsnet/nfc/llcp_core.c+2 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH net 0/3] nfc: fix skb leaks in LLC nop and in data exchange error paths

Three skb leaks in the NFC core, found by LLM-assisted code review while auditing the HCI drivers that need real hardware.

Patch 1: with the LLC "nop" engine (used by the MEI attached pn544 and microread) every frame sent to the controller is leaked. Confirmed with a test-only module that registers st21nfca with LLC nop on a virtual phy and a userspace controller emulator: 20 device up/down cycles leak 598 skbuff_head_cache objects without the patch and none with it.

Patches 2 and 3: the HCI core and the HCI drivers (pn544, st21nfca, microread) hand the response skb to the data exchange callback together with an error when the controller reports a failed exchange, and NCI does the same for a frame interface status error, but the raw socket and LLCP callbacks only free the skb on success. These two are compile tested only (W=1); the leak follows from the code: __nfc_hci_cmd_completion() gives the skb to the callback and never frees it itself, and nci_add_rx_data_frag() passes it on with the error.

Joas Antonio dos Santos (3):
nfc: hci: free the skb sent through LLC nop
nfc: rawsock: free the response skb when the data exchange fails
nfc: llcp: free the response skb when the data exchange fails

 net/nfc/hci/llc_nop.c | 11 ++++++++++-
 net/nfc/llcp_core.c   |  2 ++
 net/nfc/rawsock.c     |  4 ++--
 3 files changed, 14 insertions(+), 3 deletions(-)
Signature · 1 line
2.43.0