Netdev List
 help / color / mirror / Atom feed
From: "Bin Luo (University of Electronic Science and Technology of China)" <luob87709@gmail.com>
To: oe-linux-nfc@lists.linux.dev
Cc: johan@kernel.org, david@ixit.cz, kuba@kernel.org,
	netdev@vger.kernel.org,
	"Bin Luo (University of Electronic Science and Technology of
	China)" <luob87709@gmail.com>
Subject: [PATCH v3 0/2] net/nfc: fix skb ownership and NCI status errors
Date: Mon, 23 Nov 2026 14:33:08 +0800	[thread overview]
Message-ID: <20261123063310.1267-1-luob87709@gmail.com> (raw)

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

             reply	other threads:[~2026-11-23  6:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  6:33 Bin Luo (University of Electronic Science and Technology of China) [this message]
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)

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=20261123063310.1267-1-luob87709@gmail.com \
    --to=luob87709@gmail.com \
    --cc=david@ixit.cz \
    --cc=johan@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oe-linux-nfc@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox