From: David Heidelberg <david@ixit.cz>
To: Yuchao Zhang <ndaugoing@gmail.com>, Simon Horman <horms@kernel.org>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, oe-linux-nfc@lists.linux.dev,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] nfc: nci: ignore unexpected CORE_RESET_NTF and CORE_RESET_RSP
Date: Tue, 22 Sep 2026 12:05:53 +0200 [thread overview]
Message-ID: <049e03e2-3648-4a8a-8959-d88a56545f4d@ixit.cz> (raw)
In-Reply-To: <20260922080750.35929-1-ndaugoing@gmail.com>
On 22/09/2026 10:07, Yuchao Zhang wrote:
> Commit bcd684aace34 ("net/nfc/nci: Support NCI 2.x initial sequence")
> added handling of CORE_RESET_NTF in nci_core_reset_ntf_packet(). When
> received, it updates ndev->nci_ver, ndev->manufact_id, and
> ndev->manufact_specific_info, and calls nci_req_complete(ndev,
> NCI_STATUS_OK) to finish the pending reset request.
>
> However, unlike other notification handlers in ntf.c (which validate
> ndev->state before completing requests), nci_core_reset_ntf_packet()
> does not check whether a core reset request is actually pending.
> If an unsolicited or delayed CORE_RESET_NTF arrives (e.g. after a reset
> command times out or from a misbehaving NFCC), it unconditionally:
> 1. Completes whatever request is currently in-flight (such as CORE_INIT,
> RF_DISCOVER, or CONN_CREATE) with NCI_STATUS_OK, leading to kernel
> state desynchronization.
> 2. Overwrites ndev->nci_ver and manufacturer info. Because
> ndev->nci_ver is used as a selector for subsequent packet formats
> and parsers (e.g., in nci_open_device() and nci_core_init_rsp_packet()),
> unexpectedly modifying it can cause protocol format confusion.
>
> A similar issue exists in nci_core_reset_rsp_packet(): an unexpected or
> delayed response packet can prematurely complete an unrelated in-flight
> request.
>
> Fix this by ensuring CORE_RESET_NTF and CORE_RESET_RSP are only processed
> by the core layer when a reset command is actively awaiting them:
> - Set NCI_RESET_PENDING in nci_reset_req() when sending CORE_RESET_CMD.
> - In nci_core_reset_rsp_packet(), ignore the response if NCI_RESET_PENDING
> is not set. If set, clear the flag and complete the request on failure
> or for NCI 1.x (checking skb->len >= sizeof(*rsp)).
> - In __nci_request(), ensure NCI_RESET_PENDING is cleared upon request
> completion, cancellation, or timeout.
> - In nci_core_reset_ntf_packet(), skip power-on notifications (trigger
> 0x01, identical in NCI 1.0 and 2.0), then check and clear
> NCI_RESET_PENDING before updating device fields and completing the
> request. The CORE_RESET_CMD trigger value is revision-dependent
> (0x00 in NCI 1.0, 0x02 in NCI 2.0), so both are accepted and gated
> on NCI_RESET_PENDING alone. If unexpected, log a warning and return
> 0 so driver-specific handlers (such as fdp firmware patch handling)
> still receive the notification.
>
> Fixes: bcd684aace34 ("net/nfc/nci: Support NCI 2.x initial sequence")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yuchao Zhang <ndaugoing@gmail.com>
> ---
> v2:
> - Do not abort the notification pipeline on unexpected CORE_RESET_NTF (return 0
> instead of -EINVAL), preserving driver-level hooks (e.g. fdp firmware
> patching) per Simon Horman.
> - Skip power-on notifications (trigger 0x01, identical in NCI 1.0 and 2.0)
> while gating both NCI 1.0 (0x00) and NCI 2.0 (0x02) command-triggered resets
> on NCI_RESET_PENDING alone.
> - Check NCI_RESET_PENDING in nci_core_reset_rsp_packet() to avoid completing
> unrelated requests on unexpected responses.
> - Explicitly check skb->len >= sizeof(*rsp) in nci_core_reset_rsp_packet()
> for NCI 1.x handling.
Hello Yuchao,
please never send follow-ups as part of the thread. Always send them as a
separate message (otherwise they may get lost and we already have patchwork wich
can track the submissions.
Even better, try to use tools such as b4 to submit patches (easier for you, sent
in expected format for us).
Thanks
David
next prev parent reply other threads:[~2026-09-22 10:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 1:33 [PATCH 0/1] nfc: nci: ignore unexpected CORE_RESET_NTF zjamg
2026-09-18 1:33 ` [PATCH 1/1] " zjamg
2026-09-21 12:58 ` Simon Horman
2026-09-22 8:07 ` Yuchao Zhang
2026-09-22 8:07 ` [PATCH v2] nfc: nci: ignore unexpected CORE_RESET_NTF and CORE_RESET_RSP Yuchao Zhang
2026-09-22 10:05 ` David Heidelberg [this message]
2026-09-22 10:18 ` Yuchao Zhang
2026-09-22 10:21 Yuchao Zhang
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=049e03e2-3648-4a8a-8959-d88a56545f4d@ixit.cz \
--to=david@ixit.cz \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ndaugoing@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=oe-linux-nfc@lists.linux.dev \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®