Netdev List
 help / color / mirror / Atom feed
From: Yuqi Xu <xuyuqiabc@gmail.com>
To: Simon Horman <horms@kernel.org>
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" <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 v2 1/1] nfc: digital: fix use-after-free in unregister
Date: Sat, 21 Nov 2026 18:17:30 +0800	[thread overview]
Message-ID: <20261121181730.58295-reply-xuyuqiabc@gmail.com> (raw)
In-Reply-To: <20261112151208.496636-1-horms@kernel.org>

Hi Simon,

Thanks for the review.

> [Severity: Low]
>
> The commit message presents this as part of the unregister fix ("handle
> its MD listening state in abort and shutdown"). Does this abort_cmd case
> take effect on the unregister path?

You are right that the unregister path itself reaches abort_cmd() with the
state already at PWR_OFF. The MD state handling is there so an MD listen
cannot outlive the device, and it also changes the normal stop-poll and
suspend paths. v3 describes that explicitly in the commit message so stable backports
do not treat the normal-path behaviour change as unrelated cleanup.

> [Severity: High]
>
> Can this assignment overwrite an ignore_timeout = true that the IRQ
> thread set for a timeout handler that is already running?

Valid. v3 no longer clears an ignore_timeout set by the IRQ path: shutdown
and abort only set it to true when cancel_delayed_work() reports that the
handler is already running. The handler therefore sees the flag and does
not deliver a second completion after the IRQ has completed the command.

> [Severity: High]
>
> Can a timeout handler that is already running still deliver a
> completion into a freed digital_cmd before this point?

Valid as well. v3 marks the command complete before invoking the callback
in trf7970a_send_upstream(), so a timeout handler that is already waiting
for trf->lock cannot complete the same command again. The timeout work is
also cancelled synchronously after shutdown and before unregister, so a
handler that was already running is drained while the command and device
are still alive.

> [Severity: Low]
>
> Do the in-tree implementations follow this new contract?

The contract now allows driver-side removal serialization as an
alternative to doing everything in abort_cmd(): the driver must ensure
that no completion callback can run after the command is freed, either in
abort_cmd() itself or by serializing removal before calling
nfc_digital_unregister_device(). That matches st95hf's rm_lock/nfcdev_free
scheme and trf7970a's shutdown-plus-flush scheme.

v3 has the fixes and the updated documentation, and is now sent as a
new thread.

Thanks,
Yuqi


      reply	other threads:[~2026-11-21 10:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07  6:19 [PATCH net v2 0/1] nfc: digital: fix use-after-free in unregister Yuqi Xu
2026-11-07  6:19 ` [PATCH net v2 1/1] " Yuqi Xu
2026-11-12 15:12   ` Simon Horman
2026-11-21 10:17     ` Yuqi Xu [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=20261121181730.58295-reply-xuyuqiabc@gmail.com \
    --to=xuyuqiabc@gmail.com \
    --cc=davem@davemloft.net \
    --cc=david@ixit.cz \
    --cc=dmitry.torokhov@gmail.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --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 \
    /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