From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796221506; b=R9uIq5zkW/1VqzQbEaSQoc00xgjdaei1be1anIgPpVKz6Og7iJeT4yYRoJ9S0e+cojZo GDsZpfWhwq3U4pxubpItzvRrfzNM8kMMgStFQFY512r0WJjnBbtTTWw7BJBwOYuMq+rqP +bm4wrwMeZA6doHp76fmGl8kYlu0FQ6Qxf35HGUmnxravEJE3YxLndjsftcL+eVFQrSXD 7Bbpv7YCucudmAX+vhUWHdfVS04C2JakmIRJ5hNt3cUhgc3IaBgnpWfbQ+31Mt+mbHG1A sjgC5dBinBtR3xNTTpIJUHfytLM78b84zfWs/XYXMWDZQpHJupIRvk5KgIVFFUct+tA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796221506; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=4aooaN3Ymmgk5/Q/V1MgwAr5msI2QA9Pp2pVRJgyVpE=; b=Rjo6Wq5xPe2WMC4HL6Sytll2+qtKntD6XBkl0oBjkpSw8bz1YNYFlCmPy8nzZ80AkQWd D/8IIux1Ls4y1gyhf5+xo6uXLofANu6o5kF0GDG8Q/iCwD7SQHGBWKVqdvXsD0SxPqBfN QKM+7PmyiWKch7esJdP8k5yEbxnH647NHDtUxmcU1t/Y/V6HxH60Bg2Z2HsAgczXUJnuA CSxL+5M5Gka+R5u9K3CKBv5i5qJT1IrfferIB+BKXZLSuh1yGKe3+iKEqYQqtKOI2i70/ dzDawtIRj9klE37kpRyJiHLzd6lVvhI9u4XLhcQthvc7I32kDuOa7XKF5qUEvb5VKCA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=rTs9NmaV; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83E93606A31A for ; Wed, 2 Dec 2026 14:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=rTs9NmaV Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B48C1F000C1; Wed, 2 Dec 2026 14:25:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796221506; bh=4aooaN3Ymmgk5/Q/V1MgwAr5msI2QA9Pp2pVRJgyVpE=; h=Subject:To:Cc:From:Date; b=rTs9NmaVOVlS6FABRbG5rmXs+JQU9VKvH2+Wd+fBDf8dVeMyHDeDd5qFzrbrEDfdW pHhXr8U/gFpV/xHSUpD2SeX09ehXMMrIvrMdG7wPLp6v+PIliH9xDpGHIjHtZmHGHS wWGnPYu5WfBs+hgWDc3I/vOIr9aDcIsQNrmJg53M= Subject: FAILED: patch "[PATCH] nvmet-auth: store the DH-CHAP key offset instead of" failed to apply to 6.12-stable tree To: shao.mingyin@zte.com.cn,hch@lst.de,kbusch@kernel.org Cc: From: Date: Wed, 02 Dec 2026 14:53:23 +0100 Message-ID: <2026120223-numbness-doorframe-62cd@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.12-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y git checkout FETCH_HEAD git cherry-pick -x 62dae895f986f7459fea1deebd89a0bce76a886f # git commit -s git send-email --to '' --in-reply-to '2026120223-numbness-doorframe-62cd@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 62dae895f986f7459fea1deebd89a0bce76a886f Mon Sep 17 00:00:00 2001 From: Shao Mingyin Date: Mon, 9 Nov 2026 22:59:21 +0800 Subject: [PATCH] nvmet-auth: store the DH-CHAP key offset instead of hardcoding it nvmet_auth_set_key() accepts variable-width hash identifiers, but nvmet_setup_auth() always skips ten bytes before extracting the key. For "DHHC-1:1:" this starts one byte past the allocated string's NUL terminator, causing an out-of-bounds read in nvme_auth_extract_key(). Other nonstandard prefix widths also select the wrong key bytes. Use %n to validate the complete prefix and record its actual length for both host and controller secrets. Keep the offsets as int, matching the scan result, so whitespace or leading zeroes in the hash identifier do not truncate the saved offset. Fixes: db1312dd9548 ("nvmet: implement basic In-Band Authentication") Cc: stable@vger.kernel.org Signed-off-by: Shao Mingyin Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch diff --git a/drivers/nvme/target/auth.c b/drivers/nvme/target/auth.c index 8ca5a061d565..a4a2a5cfd823 100644 --- a/drivers/nvme/target/auth.c +++ b/drivers/nvme/target/auth.c @@ -24,6 +24,7 @@ int nvmet_auth_set_key(struct nvmet_host *host, const char *secret, { unsigned char key_hash; char *dhchap_secret; + int offset = 0; if (!strlen(secret)) { down_write(&nvmet_config_sem); @@ -31,15 +32,18 @@ int nvmet_auth_set_key(struct nvmet_host *host, const char *secret, kfree(host->dhchap_ctrl_secret); host->dhchap_ctrl_secret = NULL; host->dhchap_ctrl_key_hash = 0; + host->dhchap_ctrl_key_offset = 0; } else { kfree(host->dhchap_secret); host->dhchap_secret = NULL; host->dhchap_key_hash = 0; + host->dhchap_key_offset = 0; } up_write(&nvmet_config_sem); return 0; } - if (sscanf(secret, "DHHC-1:%hhd:%*s", &key_hash) != 1) + if (sscanf(secret, "DHHC-1:%hhd:%n", &key_hash, &offset) != 1 || + !offset) return -EINVAL; if (key_hash > 3) { pr_warn("Invalid DH-HMAC-CHAP hash id %d\n", @@ -54,10 +58,12 @@ int nvmet_auth_set_key(struct nvmet_host *host, const char *secret, kfree(host->dhchap_ctrl_secret); host->dhchap_ctrl_secret = strim(dhchap_secret); host->dhchap_ctrl_key_hash = key_hash; + host->dhchap_ctrl_key_offset = offset; } else { kfree(host->dhchap_secret); host->dhchap_secret = strim(dhchap_secret); host->dhchap_key_hash = key_hash; + host->dhchap_key_offset = offset; } up_write(&nvmet_config_sem); return 0; @@ -186,14 +192,16 @@ u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq, bool reset) * Skip the 'DHHC-1:XX:' prefix. Keep the old keys until the new ones * are there: a controller without a host key needs no authentication. */ - host_key = nvme_auth_extract_key(host->dhchap_secret + 10, + host_key = nvme_auth_extract_key(host->dhchap_secret + + host->dhchap_key_offset, host->dhchap_key_hash); if (IS_ERR(host_key)) { ret = NVME_AUTH_DHCHAP_FAILURE_NOT_USABLE; goto out_unlock; } if (host->dhchap_ctrl_secret) { - ctrl_key = nvme_auth_extract_key(host->dhchap_ctrl_secret + 10, + ctrl_key = nvme_auth_extract_key(host->dhchap_ctrl_secret + + host->dhchap_ctrl_key_offset, host->dhchap_ctrl_key_hash); if (IS_ERR(ctrl_key)) { nvme_auth_free_key(host_key); diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h index 2c2460ef5e2b..e33884a81efc 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -401,6 +401,8 @@ struct nvmet_host { struct config_group group; u8 *dhchap_secret; u8 *dhchap_ctrl_secret; + int dhchap_key_offset; + int dhchap_ctrl_key_offset; u8 dhchap_key_hash; u8 dhchap_ctrl_key_hash; u8 dhchap_hash_id;