[PATCH v3 2/2] nvme-auth: fix data race on ctrl->transaction

Hannes Reinecke hare at suse.de
Mon Nov 16 05:22:51 PST 2026


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 as it carries controller-specific data we should also ensure
the ID is unique per controller, ensuring we catch any possible
misdirected authentication packet.

It should be possible to move the controller value to an atomic
value, and then we could do

chap->transaction = atomic_inc_return(&ctrl->transaction);

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare at suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich



More information about the Linux-nvme mailing list