From: David Heidelberg <david@ixit.cz>
To: Sanghyun Park <sanghyun.park.cnu@gmail.com>,
Krzysztof Kozlowski <krzk@kernel.org>
Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Ian Ray <ian.ray@gehealthcare.com>, Joe Damato <joe@dama.to>,
Kuniyuki Iwashima <kuniyu@google.com>,
Kees Cook <kees@kernel.org>,
Ashutosh Desai <ashutoshdesai993@gmail.com>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
Deepak Sharma <deepak.sharma.472935@gmail.com>,
Michael Thalmeier <michael.thalmeier@hale.at>,
Christophe Ricard <christophe.ricard@gmail.com>,
Samuel Ortiz <sameo@linux.intel.com>,
oe-linux-nfc@lists.linux.dev, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v4] nfc: nci: Fix conn_info use-after-free
Date: Tue, 11 Aug 2026 20:23:02 +0200 [thread overview]
Message-ID: <8e5c2ea4-53fe-4dd5-ac71-5bb3ab5ee911@ixit.cz> (raw)
In-Reply-To: <20260723022407.3402916-2-sanghyun.park.cnu@gmail.com>
On 23/07/2026 04:24, Sanghyun Park wrote:
> nci_tx_work() looks up conn_info from conn_info_list and keeps using
> that pointer while sending queued data. nci_core_conn_close_rsp_packet()
> runs on the separate rx_wq and can remove and free the same conn_info,
> so the tx worker can dereference freed memory.
>
> The same lifetime rule also has to cover other conn_info_list users and
> the direct rf_conn_info and hci_dev->conn_info aliases. Protect
> conn_info_list and conn_info pointer aliases with a dedicated lock, use
> it while publishing and removing entries, and keep readers under the lock
> while they dereference conn_info or copy the fields they need.
>
> In nci_tx_work(), take the lock only around lookup, credit checks, skb
> dequeue, and credit accounting so close cannot free conn_info while it is
> used, but transport send latency does not block rx_wq response
> processing.
>
> Fixes: 736bb9577407 ("NFC: nci: Support logical connections management")
> Signed-off-by: Sanghyun Park <sanghyun.park.cnu@gmail.com>
> ---
> v4:
> - Guard hci_dev before clearing its conn_info alias during teardown.
> - Reflow lines flagged by the netdev 80-column check.
> - Use the current NFC maintainer address from MAINTAINERS.
> v3: https://lore.kernel.org/netdev/20260630071717.3618185-2-sanghyun.park.cnu@gmail.com/
> - Add Fixes tag for the logical connection close lifetime bug.
> - Add the missing NFC maintainer and oe-linux-nfc list.
> - Cover all conn_info_list helper users, not only nci_tx_work().
> - Protect direct rf_conn_info and hci_dev->conn_info aliases.
> - Publish and remove conn_info entries under the same lock.
> - Protect RF conn_info discovery publication with the same lock.
> - Keep HCI rx_skb immediate dereferences under conn_info_lock.
> - Narrow nci_send_data() lock coverage around skb queueing.
> - Avoid holding conn_info_lock across nci_send_frame().
> - Use spin_lock_bh() so HCI timer callbacks do not take a sleepable lock.
> - Keep conn_info_lock alive until nci_dev teardown instead of destroying it before nfc_remove_device().
> v2: https://patchwork.kernel.org/project/netdevbpf/patch/20260610081657.686636-1-sanghyun.park.cnu@gmail.com/
> - Replace flush-only fix with conn_info locking around tx and close.
> v1: https://patchwork.kernel.org/project/netdevbpf/patch/CAOrxSK5UmFFfzdRG+P89+E+Rvg_1DmOvTs+M7353Q8=hkPXmSg@mail.gmail.com/
>
> drivers/nfc/st-nci/se.c | 16 +++---
> include/net/nfc/nci_core.h | 9 ++-
> net/nfc/nci/core.c | 98 +++++++++++++++++++++++++--------
> net/nfc/nci/data.c | 68 ++++++++++++++---------
> net/nfc/nci/hci.c | 109 +++++++++++++++++++++++++++++--------
> net/nfc/nci/ntf.c | 23 ++++++--
> net/nfc/nci/rsp.c | 52 +++++++++++++-----
> 7 files changed, 271 insertions(+), 104 deletions(-)
>
Hello Sanghyun,
thank you for the patch, LGMT. Could you please rebase against
https://codeberg.org/linux-nfc/linux/src/branch/for-linus
There is a small conflict in the rsp.c
Thanks!
David
next prev parent reply other threads:[~2026-08-11 18:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 2:24 [PATCH net v4] nfc: nci: Fix conn_info use-after-free Sanghyun Park
2026-08-11 18:23 ` David Heidelberg [this message]
2026-08-12 7:34 ` Sanghyun Park
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=8e5c2ea4-53fe-4dd5-ac71-5bb3ab5ee911@ixit.cz \
--to=david@ixit.cz \
--cc=ashutoshdesai993@gmail.com \
--cc=christophe.ricard@gmail.com \
--cc=davem@davemloft.net \
--cc=deepak.sharma.472935@gmail.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=ian.ray@gehealthcare.com \
--cc=joe@dama.to \
--cc=kees@kernel.org \
--cc=krzk@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.thalmeier@hale.at \
--cc=netdev@vger.kernel.org \
--cc=oe-linux-nfc@lists.linux.dev \
--cc=pabeni@redhat.com \
--cc=sameo@linux.intel.com \
--cc=sanghyun.park.cnu@gmail.com \
--cc=vadim.fedorenko@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