From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EE273126B2 for ; Thu, 16 Apr 2026 06:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776320618; cv=none; b=eJKjtKkm6KiOiZNGz0PSbrFyc0J6qZueWtObMw2ui0KbYfaLirV+EBJHhlMF+DjafqhzwedoLtAc2e93AVkcFnmiXNkuzLz+8+HUdOQggOieOyK8+Po1vtl9YZC//54ZDSdlQUc3DGNf28sdAQgdFLlGeXfetUnRsLiO6EfeZt8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776320618; c=relaxed/simple; bh=ZJow/K7yMfdijsQ4LCQ7cR2uPlzUYRFqgQz87ZjX6XI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=AQMZyPV1woZac+Kx5NPK+FOg05ysRKw7W0pH/4qzSx6NRa6ECC51lttpA6tFQ8TLG7vFLaR/xpL3RXxcP+vvh4ZgAR7Fg/ONi/MrzwykZ/jvXiVniJTAiW4epvsOaOfqZCBX4Bas/vR6lXrUyBJr/L0Gcblba/KOwxiu5HryaMw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=1yAzBLdN; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=kXrnUpzw; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=1yAzBLdN; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=kXrnUpzw; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="1yAzBLdN"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="kXrnUpzw"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="1yAzBLdN"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="kXrnUpzw" 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-out1.suse.de (Postfix) with ESMTPS id C4DA76A7EC; Thu, 16 Apr 2026 06:23:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776320614; 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=JXL/gFeiqcH8qxfzidbSPF6LwgApb+dnTaxN3parvkY=; b=1yAzBLdNWcvtHKnsPJCy6dzBEaQ+lpM9txrE+BnglMfyaHqb78md8gE+Fokxf0Gelc6rEG hshAUQMwIn6UtwFSR1m3lfr4BuovQm9h68/NfpQue9/vgnMKSOQMrC0OjxakhrCMZgb2DM omZ805HNoxDh4w4VrX0Bz/NFJoIvqHc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776320614; 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=JXL/gFeiqcH8qxfzidbSPF6LwgApb+dnTaxN3parvkY=; b=kXrnUpzwLxbWHEXihzjfwYFt5ifsLZQyf40wlXCK4A3N96O3ITMeir+JjkHKAE16pggCsn BdZO1h53/ie0f9Dg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776320614; 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=JXL/gFeiqcH8qxfzidbSPF6LwgApb+dnTaxN3parvkY=; b=1yAzBLdNWcvtHKnsPJCy6dzBEaQ+lpM9txrE+BnglMfyaHqb78md8gE+Fokxf0Gelc6rEG hshAUQMwIn6UtwFSR1m3lfr4BuovQm9h68/NfpQue9/vgnMKSOQMrC0OjxakhrCMZgb2DM omZ805HNoxDh4w4VrX0Bz/NFJoIvqHc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776320614; 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=JXL/gFeiqcH8qxfzidbSPF6LwgApb+dnTaxN3parvkY=; b=kXrnUpzwLxbWHEXihzjfwYFt5ifsLZQyf40wlXCK4A3N96O3ITMeir+JjkHKAE16pggCsn BdZO1h53/ie0f9Dg== 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 84E834BDFD; Thu, 16 Apr 2026 06:23:34 +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 Y52XHmaA4GnnLwAAD6G6ig (envelope-from ); Thu, 16 Apr 2026 06:23:34 +0000 Message-ID: <9565c130-1a5c-48e9-8517-0c8a3f805bb6@suse.de> Date: Thu, 16 Apr 2026 08:23:34 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] nvme-auth: Include SC_C in RVAL controller hash To: alistair23@gmail.com, kbusch@kernel.org, axboe@kernel.dk, hch@lst.de, sagi@grimberg.me, kch@nvidia.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alistair Francis References: <20260415230824.2790058-1-alistair.francis@wdc.com> Content-Language: en-US From: Hannes Reinecke In-Reply-To: <20260415230824.2790058-1-alistair.francis@wdc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[gmail.com,kernel.org,kernel.dk,lst.de,grimberg.me,nvidia.com,lists.infradead.org,vger.kernel.org]; RCPT_COUNT_SEVEN(0.00)[9]; FUZZY_RATELIMITED(0.00)[rspamd.com]; MID_RHS_MATCH_FROM(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email,wdc.com:email]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,wdc.com:email] X-Spam-Flag: NO X-Spam-Score: -4.30 X-Spam-Level: On 4/16/26 01:08, alistair23@gmail.com wrote: > From: Alistair Francis > > Section 8.3.4.5.5 of the NVMe Base Specification 2.1 describes what is > included in the Response Value (RVAL) hash and SC_C should be included. > Currently we are hardcoding 0 instead of using the correct SC_C value. > > Update the host and target code to use the SC_C when calculating the > RVAL instead of using 0. > > Fixes: f50fff73d620 ("nvme: implement In-Band authentication") > Signed-off-by: Alistair Francis > --- > v2: > - Rebase using new nvme_auth_hmac_update() functions > > drivers/nvme/host/auth.c | 3 ++- > drivers/nvme/target/auth.c | 3 ++- > 2 files changed, 4 insertions(+), 2 deletions(-) > I would argue that this is a fix to secure concatenation, as the original implementation (ie the quoted commit) did not support secure concatenation (which sets 'sc_c' to a non-zero value). Can you adapt the 'Fixes' line? > diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c > index bbedbe181c8a6..63f543e809985 100644 > --- a/drivers/nvme/host/auth.c > +++ b/drivers/nvme/host/auth.c > @@ -535,11 +535,12 @@ static int nvme_auth_dhchap_setup_ctrl_response(struct nvme_ctrl *ctrl, > put_unaligned_le16(chap->transaction, buf); > nvme_auth_hmac_update(&hmac, buf, 2); > > - memset(buf, 0, 4); > + *buf = chap->sc_c; > nvme_auth_hmac_update(&hmac, buf, 1); > nvme_auth_hmac_update(&hmac, "Controller", 10); > nvme_auth_hmac_update(&hmac, ctrl->opts->subsysnqn, > strlen(ctrl->opts->subsysnqn)); > + memset(buf, 0, 4); > nvme_auth_hmac_update(&hmac, buf, 1); > nvme_auth_hmac_update(&hmac, ctrl->opts->host->nqn, > strlen(ctrl->opts->host->nqn)); > diff --git a/drivers/nvme/target/auth.c b/drivers/nvme/target/auth.c > index b34610e2f19d4..f032855b21477 100644 > --- a/drivers/nvme/target/auth.c > +++ b/drivers/nvme/target/auth.c > @@ -402,11 +402,12 @@ int nvmet_auth_ctrl_hash(struct nvmet_req *req, u8 *response, > put_unaligned_le16(req->sq->dhchap_tid, buf); > nvme_auth_hmac_update(&hmac, buf, 2); > > - memset(buf, 0, 4); > + *buf = req->sq->sc_c; > nvme_auth_hmac_update(&hmac, buf, 1); > nvme_auth_hmac_update(&hmac, "Controller", 10); > nvme_auth_hmac_update(&hmac, ctrl->subsys->subsysnqn, > strlen(ctrl->subsys->subsysnqn)); > + memset(buf, 0, 4); > nvme_auth_hmac_update(&hmac, buf, 1); > nvme_auth_hmac_update(&hmac, ctrl->hostnqn, strlen(ctrl->hostnqn)); > nvme_auth_hmac_final(&hmac, response); Otherwise looks good. 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