From nobody Thu Apr 2 17:36:32 2026 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 B57BA286A7 for ; Thu, 12 Feb 2026 01:34:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770860095; cv=none; b=qaF9ILqNqh634RNjUGcfmYCs0j4HTxUNxT4gGFn4zclz6TSyCN0lbeE2GAE+xRTee7m6ruqiGy+R2+6nEERxSRX6wqzVMjoiMaKEBlhc8nY5EbPA4sERPbCkk/RtUHyR7vMFT7kKqBkwLxOGmOmBhl9j4OWyJo65H7WmmzEUunU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770860095; c=relaxed/simple; bh=bqEhi+dHwWhmCkn+vqimEfzsui4y4scBtseYTsVxRRY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FqvMulJeZTfer4pBjUAaFrmmX+e2hrVwTNbogzkx5OeLYxGYl+eElMG/XDfMbHubagK73y4DBSCnOA4yWVacMwFMLxQeEiTCZPf1A43yhkZo3yn0BtIxCh+zZFydrvtaCR/v99wPE34lT7MHoBPcEElzyPYIjjDNopFuH6LEbl0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=G25Yf2vc; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G25Yf2vc" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-82311f4070cso944778b3a.0 for ; Wed, 11 Feb 2026 17:34:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770860093; x=1771464893; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gytecfs+kP5fchWx6J1Ofd0aFrBgmLt6dmTW76I3c3s=; b=G25Yf2vc0hTsJezKMqoRA0P0cSwW2MTgyPh1wwLAKaPeQneMrNlqr3kCM5ztbDW/Qp YGbbPBwsl7xO3Z6wakPl2bteT+IAqFmJvMTWMrXsdnr8FF9GIf473cWufDS0pKT/jL2B A2SD5lL7Q6eXXunn6Cg27UO40Cx6b6Onx+D37YLdC1nRw/G6ZTQ+POb/Xz1qnD4r9oOf Dit1ryEkHoFQEEZpbJO/cvlIebqLNlPDcNucyGVfnhssgB2J9kYZuTyx4Z0oaU9ZQxOB dwTR4oDZTrxLiUdjCOrYH2M2Ba8hJGVnDDxdEO/8NAxTT0RGZoqnUGd1xvdoUFlvPXYs sbqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770860093; x=1771464893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=gytecfs+kP5fchWx6J1Ofd0aFrBgmLt6dmTW76I3c3s=; b=wXlhRHPuEVRJ/t1bybmyP+4BHySxTgvU51fdM5yyHjok1Twd7ZmgE2O20ZhSJcF/hO GJUMZYju9PaqfH4Ki+ogvnsJtSE7XDHJ+N1FYcUrLggyf4784JAttIHXwlPktu3H7c0k 512uHRQrNxoxsqHBHbccB+Wcj/afLY0a/vMtUMDmqB86G8bLOJNARAIQBotwA/dI6sB4 WaO6T5JbDPHSAaZMQ1suVR90hfcFMVRqa9S/XWiMSALnV+raf+uKbR/Z1VJjdG5ts9BX OgZS9MLzkmhRQtf/0RmRp146zy8MuPEo+W2beNdnpW+Kb3V59lcoIKRocVjcF+Qp0cAd st4g== X-Forwarded-Encrypted: i=1; AJvYcCVh00s9c/dYy41LFveFBUL5LbbQ5WGNoK16FJSESbSsa0GYOSHGtLo2BN5r8lIsx5Yp9w0CPRU5Sxtz/ag=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9Z/jsHBxgHiVTH63BzfTDRUr4PYjQiU3OT5IlEZhl03amN2ly i+0mcz+Q/aJRaBz1c9OGTxKheItQDRmlwZQVrGjjPEKCFG1xC4OrGh86 X-Gm-Gg: AZuq6aKySHFPdpnGTtTcZs2lCMkzC/Eka36kMunqyYX9xr+0hq71MZmhxB3drRZlgz3 THBE4x2NISb3swd8oDstoFokL5wFUNEN/QJoQGC0f/o0UZSNlqLMWWWuoh7VtefPzRy3hkKqsfi YJGY59QBlgU29+d7QRG7fZOnoPFq0hePOju9K+b5YaF+NLV7AXVfAMlyVE8wXRezhaA973rPsMJ DLVt58m16+ZmIvoi/gvHob9qGudJT8wHvOQIre6U3ZmOIDLavL+69LLzhbbINTxf2P+XceDCmry 6+7lr6R2Leqwi3931YafgApy471pm7Zz6lq7YNPqNiU0lhj1fYafzpfiEDaNJJaVLWxz0KvpbUt POmARe9XVsiNOwCOJbyFP9bDZoDY8Ub+AS7/sXAQRKF5vqDvj6vr1jOz43EXMgWXKGfBrmedMEc rfkfTrInCeobomlJFk+Dox7YBB9CsyG4ozF/ncT0B3Oh6c X-Received: by 2002:a05:6a00:2347:b0:81f:32cc:b1fc with SMTP id d2e1a72fcca58-824b0cb94aamr844747b3a.3.1770860092934; Wed, 11 Feb 2026 17:34:52 -0800 (PST) Received: from user-System-Product-Name.. ([210.121.152.246]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8249e80def7sm3974008b3a.44.2026.02.11.17.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Feb 2026 17:34:52 -0800 (PST) From: YunJe Shin X-Google-Original-From: YunJe Shin To: hch@lst.de Cc: hare@suse.de, ioerts@kookmin.ac.kr, kbusch@kernel.org, kch@nvidia.com, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, sagi@grimberg.me, yjshin0438@gmail.com Subject: [PATCH v2] nvmet-auth: validate negotiate payload length(BUG: KASAN: slab-out-of-bounds) Date: Thu, 12 Feb 2026 10:33:18 +0900 Message-ID: <20260212013338.1417091-1-ioerts@kookmin.ac.kr> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260211160859.GA11869@lst.de> References: <20260211160859.GA11869@lst.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Yunje Shin AUTH_SEND negotiation requires at least one DH-HMAC-CHAP protocol descripto= r. Validate the payload length before parsing the negotiate payload to avoid out-of-bounds reads. KASAN splat: [ 1224.388857] BUG: KASAN: slab-out-of-bounds in nvmet_execute_auth_send+0x= 1d24/0x2090 [ 1224.407035] The buggy address belongs to the cache kmalloc-8 of size 8 [ 1224.407998] allocated 8-byte region [ffff88800a6537c0, ffff88800a6537c8) [ 1224.412412] page dumped because: kasan: bad access detected Use struct_size() for minimum length computation and move the negotiate restart flow into a helper so the call site stays compact. Fixes: db1312dd95488 ("nvmet: implement basic In-Band Authentication") Signed-off-by: Yunje Shin Reviewed-by: Chris Leech Reviewed-by: Hannes Reinecke --- v2: - use struct_size() for negotiate payload minimum length - split negotiate handling into nvmet_restart_dhchap_auth() helper - use NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD instead of NVMe status drivers/nvme/target/fabrics-cmd-auth.c | 48 +++++++++++++++++--------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/drivers/nvme/target/fabrics-cmd-auth.c b/drivers/nvme/target/f= abrics-cmd-auth.c index 5946681cb0e3..3773980bcb1c 100644 --- a/drivers/nvme/target/fabrics-cmd-auth.c +++ b/drivers/nvme/target/fabrics-cmd-auth.c @@ -231,6 +231,36 @@ u32 nvmet_auth_send_data_len(struct nvmet_req *req) return le32_to_cpu(req->cmd->auth_send.tl); } =20 +static bool nvmet_restart_dhchap_auth(struct nvmet_req *req, void *d, u32 = tl) +{ + struct nvmet_ctrl *ctrl =3D req->sq->ctrl; + struct nvmf_auth_dhchap_negotiate_data *neg =3D d; + u8 dhchap_status; + size_t min_len =3D struct_size(neg, auth_protocol, 1); + + if (tl < min_len) { + req->sq->dhchap_status =3D NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; + req->sq->dhchap_step =3D NVME_AUTH_DHCHAP_MESSAGE_FAILURE1; + return false; + } + + /* Restart negotiation */ + pr_debug("%s: ctrl %d qid %d reset negotiation\n", + __func__, ctrl->cntlid, req->sq->qid); + if (!req->sq->qid) { + dhchap_status =3D nvmet_setup_auth(ctrl, req->sq); + if (dhchap_status) { + pr_err("ctrl %d qid 0 failed to setup re-authentication\n", + ctrl->cntlid); + req->sq->dhchap_status =3D dhchap_status; + req->sq->dhchap_step =3D NVME_AUTH_DHCHAP_MESSAGE_FAILURE1; + return false; + } + } + req->sq->dhchap_step =3D NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE; + return true; +} + void nvmet_execute_auth_send(struct nvmet_req *req) { struct nvmet_ctrl *ctrl =3D req->sq->ctrl; @@ -289,22 +319,8 @@ void nvmet_execute_auth_send(struct nvmet_req *req) goto done_failure1; if (data->auth_type =3D=3D NVME_AUTH_COMMON_MESSAGES) { if (data->auth_id =3D=3D NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE) { - /* Restart negotiation */ - pr_debug("%s: ctrl %d qid %d reset negotiation\n", - __func__, ctrl->cntlid, req->sq->qid); - if (!req->sq->qid) { - dhchap_status =3D nvmet_setup_auth(ctrl, req->sq); - if (dhchap_status) { - pr_err("ctrl %d qid 0 failed to setup re-authentication\n", - ctrl->cntlid); - req->sq->dhchap_status =3D dhchap_status; - req->sq->dhchap_step =3D - NVME_AUTH_DHCHAP_MESSAGE_FAILURE1; - goto done_kfree; - } - } - req->sq->dhchap_step =3D - NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE; + if (!nvmet_restart_dhchap_auth(req, d, tl)) + goto done_kfree; } else if (data->auth_id !=3D req->sq->dhchap_step) goto done_failure1; /* Validate negotiation parameters */ --=20 2.43.0