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 89B79606A31C for ; Tue, 17 Nov 2026 07:31:52 +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=oBVGly9I; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=JM1hpJ01; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Oput8iLO; dkim=neutral header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=JM1hpJ01; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Oput8iLO 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=TQvXSzNTL3avcAmwI1SzCAzJN21XInkCG0XQ0+uGhXc=; b=oBVGly9IW7dQwo R+hRv2WQ+IAkg5lBbub1Mm6bDw4u5n43tVnVU8Z59ADoc4RivPUdnO6DaNydnToDxXfVLxNf2jQWq 8t2DUeSox1WNxVP4DuQwdpMP5pdrxEyNu2nPwa+mjzNvDBq/ZxKGiHPbKTiPu+tu0WrxBvKjfHZNs h+OadMt/2c3bHhgB2ATPa8xNJn1Zk79zHpwX81dc8hW0Os9Pe7pENfaVx9B9Qbqwue5Mcv0HhyteY x4Yj6lY+VyaVhyAvp1FndsTnnJoHyIBfh7dmjBvwZSPV7pIY4vi17kTVEbVtl0Q6XdwtBQoJ0Z8Ws RfWR0dQA5sTDhvPfKltg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xTDfT-00000004mdv-2cbc; Tue, 17 Nov 2026 07:31:51 +0000 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xTDfQ-00000004mdW-2Xdt for linux-nvme@lists.infradead.org; Tue, 17 Nov 2026 07:31:49 +0000 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 924E41F789; Tue, 17 Nov 2026 07:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1794900706; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TQvXSzNTL3avcAmwI1SzCAzJN21XInkCG0XQ0+uGhXc=; b=JM1hpJ01SQW35GlzDsj6NWwuCdt1+7irCKGIlYO2Yl2w0pVHY6Ob8NaRTuJbcoDBPJUsSB HbXk7VMb4oSppb+EXnE+7X6QJSRJZ2BgUN8zur1/kd/V4kehl7pUPZ4GtXKpZsk3j1jVdr YEkRhSuP1RDstjJ/yLMPS+M3clxretE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1794900706; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TQvXSzNTL3avcAmwI1SzCAzJN21XInkCG0XQ0+uGhXc=; b=Oput8iLOmQmiHuOrIc56yn2bHYg+dPAEdxVeuTEdvR293vAWMg8ihSB6UqMZTImg18bbLn 8k4D6nUpRHaDqOBg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1794900706; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TQvXSzNTL3avcAmwI1SzCAzJN21XInkCG0XQ0+uGhXc=; b=JM1hpJ01SQW35GlzDsj6NWwuCdt1+7irCKGIlYO2Yl2w0pVHY6Ob8NaRTuJbcoDBPJUsSB HbXk7VMb4oSppb+EXnE+7X6QJSRJZ2BgUN8zur1/kd/V4kehl7pUPZ4GtXKpZsk3j1jVdr YEkRhSuP1RDstjJ/yLMPS+M3clxretE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1794900706; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TQvXSzNTL3avcAmwI1SzCAzJN21XInkCG0XQ0+uGhXc=; b=Oput8iLOmQmiHuOrIc56yn2bHYg+dPAEdxVeuTEdvR293vAWMg8ihSB6UqMZTImg18bbLn 8k4D6nUpRHaDqOBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3701313302; Tue, 17 Nov 2026 07:31:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id EKUpO+EC/GqRBwAAD6G6ig (envelope-from ); Tue, 17 Nov 2026 07:31:46 +0000 Message-ID: Date: Tue, 17 Nov 2026 08:31:45 +0100 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: Guixin Liu , 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> Content-Language: en-US From: Hannes Reinecke In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-13.29 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-0.998]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; RCPT_COUNT_SEVEN(0.00)[8]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email] X-Spam-Score: -13.29 X-Spam-Level: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261116_233148_811667_9A3DA53E X-CRM114-Status: GOOD ( 16.39 ) X-Spam-Score: -2.1 (--) 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=-7.4 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,USER_AGENT_SANE_1 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 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@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