From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E15A606A31C for ; Tue, 17 Nov 2026 02:16:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=rei+8mz9; dkim=pass (1024-bit key, unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=LCACTMBG DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=S17O1sc4t+6r5xSJ/Amlorry29rij7vTqsRl4dT03rs=; b=rei+8mz9M2nmzE aayROyIzKuzOQvpWHErJ3Khk4N1PeqWpViKgI00lnzodf20hhRgwhsn7CVzLexgpdRs3lNo1Ycaxm OxNwCu2uK1JZVKzW6C10/eo1t3ewyH/bNhcD9a0zUQ8bZ6j5+RRlhIqY1msGUXoQNjctkz8yvo56H w0whnNlDa4yBuRMPb2T0cYh/bV93S2SGYe5T/VodtN6GkpQp5p5dfpMhAYCcHtQSz5pyyDmEdVMPn 3fX5VuvNOHC/uZvuRn+2cUPEMQnIiQtPsimPEdkX6zixL9v9DaPa4xRPcIejkgnDZ2YGCZhJvrhuv PanWCoyKZy+0FyEUznDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xT8kF-00000004O75-3IXe; Tue, 17 Nov 2026 02:16:27 +0000 Received: from out30-101.freemail.mail.aliyun.com ([115.124.30.101]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xT8kC-00000004O6X-0Fol for linux-nvme@lists.infradead.org; Tue, 17 Nov 2026 02:16:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1794881778; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=S17O1sc4t+6r5xSJ/Amlorry29rij7vTqsRl4dT03rs=; b=LCACTMBGwGVArYky2sTDjDMVe9q6bsFWu7Z5GxnFMnlw+UyvylIRio9fT/1PMInv3Lt3VnxolC9alTW9VTEbyzpw75IjqMZD3GuqnMqvRFIO8/bRVD+JJT190Bj6R8CrXZ6wwPrurKzI39cB4sd+sXUM6e15O/eQIJBAyzU8Q54= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045098064;MF=kanie@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0XEwaSN4_1794881775; Received: from 30.178.69.11(mailfrom:kanie@linux.alibaba.com fp:SMTPD_---0XEwaSN4_1794881775 cluster:ay36) by smtp.aliyun-inc.com; Tue, 17 Nov 2026 10:16:16 +0800 Message-ID: Date: Tue, 17 Nov 2026 10:16:15 +0800 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/2] nvme-auth: fix data race on ctrl->transaction To: Hannes Reinecke , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Nilay Shroff , Daniel Wagner Cc: linux-nvme@lists.infradead.org References: <20261116081211.1757155-1-kanie@linux.alibaba.com> <20261116081211.1757155-3-kanie@linux.alibaba.com> <6dc083eb-7286-418b-92fe-f7245f653ba0@suse.de> From: Guixin Liu In-Reply-To: <6dc083eb-7286-418b-92fe-f7245f653ba0@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261116_181624_798483_290893F1 X-CRM114-Status: GOOD ( 14.73 ) X-Spam-Score: -17.6 (-----------------) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" X-Spam-Status: No, score=-14.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 在 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