From: Simon Horman <horms@kernel.org>
To: Yuqi Xu <xuyuqiabc@gmail.com>
Cc: netdev@vger.kernel.org, oe-linux-nfc@lists.linux.dev,
"David Heidelberg" <david@ixit.cz>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
stable@vger.kernel.org, Vega <vega@nebusec.ai>,
"Ren Wei" <weir@nebusec.ai>,
xuyq21@lenovo.com, "Mark Greer" <mgreer@animalcreek.com>,
"Uwe Kleine-König (The Capable Hub)"
<u.kleine-koenig@baylibre.com>,
"Ian Ray" <ian.ray@gehealthcare.com>,
"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Thierry Escande" <thierry.escande@linux.intel.com>,
"Samuel Ortiz" <sameo@linux.intel.com>
Subject: Re: [PATCH net 1/1] nfc: digital: fix use-after-free in unregister
Date: Thu, 29 Oct 2026 10:22:21 +0000 [thread overview]
Message-ID: <20261029102221.GF257209@horms.kernel.org> (raw)
In-Reply-To: <1792999448.107874-2-xuyuqiabc@gmail.com>
On Mon, Oct 26, 2026 at 03:24:07PM +0800, Yuqi Xu wrote:
> nfc_digital_unregister_device() cancels its own workqueue items and
> then frees every queued digital_cmd. A command already submitted to
> the driver remains the argument of the async completion.
> digital_send_cmd_complete() can still assign cmd->resp after that
> object has been freed, which is a use-after-free.
>
> Abort the in-flight driver command before reclaiming the queue, and
> drain the completion work the driver may schedule from abort. Once
> the nfc device is shutting down, do not queue or submit another
> command: finishing the aborted one would otherwise hand the next
> queued command to the driver while it is being freed.
>
> Port100 and nfcsim invoke the digital completion from a private work
> item, so flush that work before abort returns. trf7970a completes from
> a delayed timeout work and from its IRQ thread; handle its MD listening
> state in abort and shutdown, and stop the timer before the device is
> released. st95hf's IRQ thread can observe that remove already ran and
> must not call back into the freed command.
>
> Fixes: 59ee2361c924 ("NFC Digital: Implement driver commands mechanism")
> Cc: stable@vger.kernel.org
> Reported-by: Vega <vega@nebusec.ai>
> Assisted-by: LLM
> Signed-off-by: Yuqi Xu <xuyuqiabc@gmail.com>
> Reviewed-by: Ren Wei <weir@nebusec.ai>
Reviewed-by: Simon Horman <horms@kernel.org>
prev parent reply other threads:[~2026-10-29 10:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 7:24 [PATCH net 0/1] nfc: digital: fix use-after-free in unregister Yuqi Xu
2026-10-26 7:24 ` [PATCH net 1/1] " Yuqi Xu
2026-10-29 10:22 ` Simon Horman [this message]
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=20261029102221.GF257209@horms.kernel.org \
--to=horms@kernel.org \
--cc=davem@davemloft.net \
--cc=david@ixit.cz \
--cc=dmitry.torokhov@gmail.com \
--cc=edumazet@google.com \
--cc=ian.ray@gehealthcare.com \
--cc=kuba@kernel.org \
--cc=mgreer@animalcreek.com \
--cc=netdev@vger.kernel.org \
--cc=oe-linux-nfc@lists.linux.dev \
--cc=pabeni@redhat.com \
--cc=sameo@linux.intel.com \
--cc=stable@vger.kernel.org \
--cc=thierry.escande@linux.intel.com \
--cc=u.kleine-koenig@baylibre.com \
--cc=vega@nebusec.ai \
--cc=weir@nebusec.ai \
--cc=xuyq21@lenovo.com \
--cc=xuyuqiabc@gmail.com \
/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