[PATCH 0/1] nfc: nci: ignore unexpected CORE_RESET_NTF

From: zjamg

Date: Thu Sep 17 2026 - 21:45:28 EST


From: Yuchao Zhang <ndaugoing@xxxxxxxxx>

Hello,

This patch addresses an issue in the NCI core stack where an unexpected
or unsolicited CORE_RESET_NTF packet can prematurely complete unrelated
in-flight requests with NCI_STATUS_OK and corrupt protocol version state.

Problem Overview:
=================
Commit bcd684aace34 ("net/nfc/nci: Support NCI 2.x initial sequence")
added nci_core_reset_ntf_packet() to handle NCI 2.x CORE_RESET
notifications. When received, it updates ndev->nci_ver and manufacturer
information, and calls nci_req_complete(ndev, NCI_STATUS_OK).

Unlike other notification handlers in ntf.c (which validate ndev->state
before acting), nci_core_reset_ntf_packet() does not verify whether a
core reset request is actually pending.

If an unsolicited or delayed CORE_RESET_NTF is received:
1. If another request is currently in-flight (such as CORE_INIT,
RF_DISCOVER, or CONN_CREATE), it prematurely completes that request
with NCI_STATUS_OK, leading to state desynchronization.
2. Even when no request is in-flight, it unconditionally overwrites
ndev->nci_ver and manufacturer info. Because ndev->nci_ver acts as
a parser and packet format selector (e.g., in nci_open_device() and
nci_core_init_rsp_packet()), unexpectedly modifying it can cause
protocol format confusion.

Solution:
=========
Introduce an NCI_RESET_PENDING flag in enum nci_flag to ensure
CORE_RESET_NTF is only accepted while a reset command is actively
awaiting it.

Testing:
========
Verified with module compilation and checkpatch.pl (0 errors, 0 warnings).
Empirically confirmed that unsolicited CORE_RESET_NTF packets are safely
rejected with a warning while legitimate reset sequences continue to
complete normally.

Thanks,
Yuchao Zhang

Yuchao Zhang (1):
nfc: nci: ignore unexpected CORE_RESET_NTF

include/net/nfc/nci_core.h | 1 +
net/nfc/nci/core.c | 3 +++
net/nfc/nci/ntf.c | 5 +++++
net/nfc/nci/rsp.c | 15 ++++++++++-----
4 files changed, 19 insertions(+), 5 deletions(-)

--
2.53.0