From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C3A713A258 for ; Fri, 13 Mar 2026 15:30:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773415830; cv=none; b=edaWGd2RGmZFp6Z0UnGekxF6Okihs35gBTCU5zU9kvrR6likHwhHp1jnNir8TafyABqty+65rSFhd9qloIuBl5+ILBHSVkeKK90Rxcqb3Zy0cxPP1IpWOxs0odJwlxEFKvSqaFgdLCkgbKGCUu7cLSIn22FXZwS+HOk5Nd7ySes= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773415830; c=relaxed/simple; bh=ulBrwMycEkg4X99VM6+guGq2tBaTQPcgfXII3bn8vPU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jV/apH/bpFbHDezzDdPs1//Ao9qMXo1138fhJq5q8yFMjqCp/hdCfpMLbIBcKa3FE/BHsuhxedwIRW2Zr7RYZwKuagXQpFupm7Rm+JK9CveEOCDCdvpqjkVRc6S5lTK3aUZcTeH5/Ou1MPu8BTnlrCBoIUzt0OtLRxH7lX0ji8g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LPpnbokB; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LPpnbokB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773415828; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LJU0YUifzg+Q61M187SOuGczoNish3+SM+1TQzx24E8=; b=LPpnbokB0/5V0/LdpS8MI1BKN0VxpOHN/H3RWiUS0enw5ZqO5KMWkHKwYVj41fy3bn2P8g PIr7L+qgR2DMws70OidLGaF2VSdJOgQdATsdw9fhg2Kf7CNcAcrhKdPDd8FUHF/HLpsM8R uMWdLfxuXu04UzN3J5tc3RYKCgUJcU0= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-475-7oC3onbHPGyr0HeZNfiUig-1; Fri, 13 Mar 2026 11:30:22 -0400 X-MC-Unique: 7oC3onbHPGyr0HeZNfiUig-1 X-Mimecast-MFC-AGG-ID: 7oC3onbHPGyr0HeZNfiUig_1773415819 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 50745195609D; Fri, 13 Mar 2026 15:30:19 +0000 (UTC) Received: from my-developer-toolbox-latest (unknown [10.2.16.140]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 3EC4619540C5; Fri, 13 Mar 2026 15:30:15 +0000 (UTC) Date: Fri, 13 Mar 2026 08:30:14 -0700 From: Chris Leech To: YunJe Shin Cc: hare@suse.de, hch@lst.de, ioerts@kookmin.ac.kr, kbusch@kernel.org, kch@nvidia.com, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, sagi@grimberg.me, stable@kernel.org Subject: Re: [PATCH v2] nvmet: auth: validate dhchap id list lengths Message-ID: <20260313-much-handbrake-cb4c6e4f1318@redhat.com> References: <20260313052444.3865842-1-ioerts@kookmin.ac.kr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260313052444.3865842-1-ioerts@kookmin.ac.kr> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 On Fri, Mar 13, 2026 at 02:24:09PM +0900, YunJe Shin wrote: > From: Yunje Shin > > The function nvmet_auth_negotiate() parses the idlist array in the > struct nvmf_auth_dhchap_protocol_descriptor payload. This array is 60 > bytes and is logically divided into two 30-byte halves: the first half > for HMAC IDs and the second half for DH group IDs. The current code > uses a hardcoded +30 offset for the DH list, but does not validate > halen and dhlen against the per-half bounds. As a result, if a > malicious host sends halen or dhlen larger than 30, the loop can > read past the 60-byte array into adjacent slab memory, triggering a > KASAN slab-out-of-bounds read. > > KASAN splat: > [ 4.241646] BUG: KASAN: slab-out-of-bounds in nvmet_execute_auth_send+0x19b8/0x2090 > [ 4.242874] Read of size 1 at addr ffff8881045754e8 by task kworker/1:1H/41 > [ 4.265342] The buggy address belongs to the cache kmalloc-96 of size 96 > [ 4.266291] allocated 72-byte region [ffff8881045754a0, ffff8881045754e8) > [ 4.270337] page dumped because: kasan: bad access detected > > This patch fixes the issue by introducing NVME_AUTH_DHCHAP_MAX_HASH_IDS > and NVME_AUTH_DHCHAP_MAX_DH_IDS defined as 30, which explicitly indicates > the maximum boundaries allowed per NVMe specification. The lengths halen > and dhlen are validated against these boundaries before processing, > preventing the out-of-bounds reads. > > Fixes: db1312dd95488 ("nvmet: implement basic In-Band Authentication") > Cc: stable@kernel.org > Signed-off-by: Yunje Shin > Reviewed-by: Hannes Reinecke > --- > v2: > - Replaced the runtime 'sizeof' calculation (idlist_half) with explicit > NVME_AUTH_DHCHAP_MAX_HASH_IDS and NVME_AUTH_DHCHAP_MAX_DH_IDS macros > to clearly reflect the 30:30 split limit per Chris Leech's feedback. Reviewed-by: Chris Leech