From: Guixin Liu <kanie@linux.alibaba.com>
To: Hannes Reinecke <hare@suse.de>, Keith Busch <kbusch@kernel.org>,
Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
Sagi Grimberg <sagi@grimberg.me>,
Nilay Shroff <nilay@linux.ibm.com>,
Daniel Wagner <dwagner@suse.de>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH v3 2/2] nvme-auth: fix data race on ctrl->transaction
Date: Tue, 17 Nov 2026 10:16:15 +0800 [thread overview]
Message-ID: <e048eab7-b8b9-4782-8f91-e79309d8be12@linux.alibaba.com> (raw)
In-Reply-To: <6dc083eb-7286-418b-92fe-f7245f653ba0@suse.de>
在 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.
Best Regards,
Guixin Liu
>
> 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
next prev parent reply other threads:[~2026-11-17 2:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 8:12 [PATCH v3 0/2] nvme: fabrics and target fixes Guixin Liu
2026-11-16 8:12 ` [PATCH v3 1/2] nvme-fc: fix use-after-free in nvme_fc_match_disconn_ls() Guixin Liu
2026-11-16 8:12 ` [PATCH v3 2/2] nvme-auth: fix data race on ctrl->transaction Guixin Liu
2026-11-16 13:22 ` Hannes Reinecke
2026-11-16 15:37 ` Keith Busch
2026-11-17 7:23 ` Hannes Reinecke
2026-11-17 2:16 ` Guixin Liu [this message]
2026-11-17 7:31 ` Hannes Reinecke
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=e048eab7-b8b9-4782-8f91-e79309d8be12@linux.alibaba.com \
--to=kanie@linux.alibaba.com \
--cc=axboe@kernel.dk \
--cc=dwagner@suse.de \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=nilay@linux.ibm.com \
--cc=sagi@grimberg.me \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.