Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Hannes Reinecke <hare@suse.de>
Cc: Guixin Liu <kanie@linux.alibaba.com>,
	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>,
	linux-nvme@lists.infradead.org
Subject: Re: [PATCH v3 2/2] nvme-auth: fix data race on ctrl->transaction
Date: Mon, 16 Nov 2026 08:37:12 -0700	[thread overview]
Message-ID: <avsjKMMlQPPit6IY@kbusch-mbp> (raw)
In-Reply-To: <6dc083eb-7286-418b-92fe-f7245f653ba0@suse.de>

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.


      reply	other threads:[~2026-11-16 15:37 UTC|newest]

Thread overview: 5+ 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 [this message]

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=avsjKMMlQPPit6IY@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=dwagner@suse.de \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kanie@linux.alibaba.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox