[PATCH v3 2/2] nvme-auth: fix data race on ctrl->transaction
Keith Busch
kbusch at kernel.org
Mon Nov 16 07:37:12 PST 2026
On Mon, Nov 16, 2026 at 02:22:51PM +0100, Hannes Reinecke wrote:
> On 11/16/26 9:12 AM, Guixin Liu wrote:
> > nvme_ctrl_auth_work() queues the DH-HMAC-CHAP exchange of every queue
> > on nvme-auth-wq without waiting for them, so multiple
> > nvme_queue_auth_work() instances run concurrently and all increment
> > ctrl->transaction in nvme_queue_auth_work(). The plain increment is a
> > data race, and the lost updates hand the same transaction id to
> > concurrent queues.
> >
> > The counter does not need to be shared at all: the controller only
> > echoes the transaction id within a queue, so a per-queue counter is
> > sufficient. Increment chap->transaction instead, drop the reset in
> > nvme_auth_reset_dhchap() so the id stays monotonic across
> > re-authentication, and remove the now unused ctrl->transaction field.
> >
> I disagree. The authentication transaction ID identifies the
> transaction itself, and is used to differentiate between different
> transactions. As such it needs to be unique within each queue.
But the proposal *is* unique within the queue. It's just not unique at
the controller level, and it sounds like the protocol doesn't need to
be.
> But as it carries controller-specific data we should also ensure
> the ID is unique per controller, ensuring we catch any possible
> misdirected authentication packet.
I don't understand. The qid:T_ID tuple already identifies the
transaction. If a controller mixes up transactions across queues, it's
already broken in ways we can't fix, so we shouldn't design around it.
> It should be possible to move the controller value to an atomic
> value, and then we could do
If there's no protocol reason to require this type of uniqueness, then
I'm not seeing why the driver is putting this constraint on itself.
More information about the Linux-nvme
mailing list