Netdev List
 help / color / mirror / Atom feed
* [PATCH v3 0/2] net/nfc: fix skb ownership and NCI status errors
@ 2026-11-23  6:33 Bin Luo (University of Electronic Science and Technology of China)
  2026-11-23  6:33 ` [PATCH v3 1/2] net/nfc: fix skb ownership on data exchange errors Bin Luo (University of Electronic Science and Technology of China)
  2026-11-23  6:33 ` [PATCH v3 2/2] nfc: preserve NCI data status error codes Bin Luo (University of Electronic Science and Technology of China)
  0 siblings, 2 replies; 3+ messages in thread
From: Bin Luo (University of Electronic Science and Technology of China) @ 2026-11-23  6:33 UTC (permalink / raw)
  To: oe-linux-nfc
  Cc: johan, david, kuba, netdev,
	Bin Luo (University of Electronic Science and Technology of China)

Hi,

This series addresses the review feedback on the v2 NFC callback-ownership
fix.

The issue was found by source inspection during a callback-ownership audit.
The NCI receive path can pass a non-NULL skb together with an error to a
data_exchange_cb_t callback. The audit found consumers and wrapper callbacks
that returned or freed only on success, leaving the response skb unconsumed.
It also found terminal Digital DEP error paths that freed exchange state
without completing the callback, and an NCI status conversion that truncated
negative errno values through __u8.

Both the baseline and v3 x86_64 kernels were fully built with NFC, Digital,
NCI, HCI/SHDLC, NFC-SIM, virtual NCI, PN533, PN544, Microread, ST21NFCA,
KASAN, and kmemleak enabled. All three full build logs contain no warning
or error lines.

The QEMU TCG test ran 32 NCI 1.0 MIFARE exchanges with status 0x01. The
harness provisioned the virtual controller and polling session, then ran
AF_NFC operations with effective UID 65534. The baseline returned
SO_ERROR=-240 instead of 16 and kmemleak reported 47 unreferenced objects.
The v3 kernel returned SO_ERROR=16, reported no unreferenced objects, and
produced no KASAN report.

A test-only KUnit overlay, not included in this series, ran ten callback
tests covering Digital DEP completion, ST21NFCA callbacks, LLCP error
release, NCI loopback and NCI-HCI errors, four HCI wrapper branches, and
PN533 response aggregation with an injected allocation failure. All ten
passed. Real NFC controller hardware was not exercised.

The final QEMU run used one vCPU. A two-vCPU KASAN boot hit an early
enqueue_task_fair int3 before userspace; it did not reach the NFC tests.

Patch 1 documents the callback ownership contract and updates the affected
consumers and providers, including terminal Digital DEP completion and
fragment cleanup. Patch 2 keeps NCI data-status errno values signed.

Best regards,
Bin Luo

Bin Luo (University of Electronic Science and Technology of China) (2):
  net/nfc: fix skb ownership on data exchange errors
  nfc: preserve NCI data status error codes

 drivers/nfc/microread/microread.c |  3 +--
 drivers/nfc/pn533/pn533.c         |  1 +
 drivers/nfc/pn544/pn544.c         |  3 +--
 drivers/nfc/st21nfca/core.c       |  3 +--
 drivers/nfc/st21nfca/dep.c        | 26 ++++++++++++-------------
 include/net/nfc/nfc.h             |  5 ++++-
 net/nfc/digital_dep.c             | 32 ++++++++++++++-----------------
 net/nfc/hci/core.c                |  5 +++--
 net/nfc/llcp_core.c               |  4 +++-
 net/nfc/nci/core.c                |  1 +
 net/nfc/nci/data.c                |  8 ++++----
 net/nfc/nci/hci.c                 |  4 ++++
 net/nfc/rawsock.c                 |  5 ++++-
 13 files changed, 54 insertions(+), 46 deletions(-)


base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-23  6:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23  6:33 [PATCH v3 0/2] net/nfc: fix skb ownership and NCI status errors Bin Luo (University of Electronic Science and Technology of China)
2026-11-23  6:33 ` [PATCH v3 1/2] net/nfc: fix skb ownership on data exchange errors Bin Luo (University of Electronic Science and Technology of China)
2026-11-23  6:33 ` [PATCH v3 2/2] nfc: preserve NCI data status error codes Bin Luo (University of Electronic Science and Technology of China)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox