[PATCH v3 2/2] nvme-auth: fix data race on ctrl->transaction
Guixin Liu
kanie at linux.alibaba.com
Mon Nov 23 04:02:43 PST 2026
在 2026/11/17 15:31, Hannes Reinecke 写道:
> 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.
Hi Hannes,
Fair point. The digest only protects the challenge and response;
Success and Failure have no such protection, and the cross-queue
distinguishability costs nothing.
Hi Keith,
Could you take this patch's v2 version instead, with the fixes
tag from v3 added (Fixes: f50fff73d620 ("nvme: implement In-Band authentication"))?
v2: https://lore.kernel.org/all/20261109022646.290792-4-kanie@linux.alibaba.com/
Best Regards,
Guixin Liu
>
> Cheers,
>
> Hannes
More information about the Linux-nvme
mailing list