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

Hannes Reinecke hare at suse.de
Mon Nov 16 23:31:45 PST 2026


On 11/17/26 3:16 AM, Guixin Liu wrote:
> 
> 
> 在 2026/11/16 21:22, Hannes Reinecke 写道:
>> 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.
> A misdirected packet is caught regardless of the transaction id.
> Each queue's exchange carries its own random challenge:
> nvmet_auth_challenge() fills req->sq->dhcahp_c1 with get_random_bytes()
> per exchange, and the response digest covers that challenge.
> A response computed for queue A fails the digest check on queue B even
> when the transaction id and the step happen to match, because the
> expected digest is different.
> 
> So controller-level uniqueness would only detect a case the crypto
> layer already rejects, while within a queue the id is unique either
> way.
> 
True, but that's valid only for challenge and response.
Success (and, more importantly, Failure) are not protected
in a similar manner. So spoofing any of these will be quite
easy if we only have per-queue transaction ids.

But as mentioned in my response to Keith: these are
primarily security concerns, and really are just stop-gap
measures to cover the most obvious issues.
In the end it's still a number and as such
not _that_ hard to guess.
So if the consensus is that the protocol provisions
are good enough it's fine with me.

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