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 31F153D0922 for ; Tue, 10 Mar 2026 18:07:13 +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=1773166035; cv=none; b=Bq/F5ywf+XD391MaBUmszWDthBRQEmnbSwmpcUAbR0p43tt6pL5d4mtwUyD7Ae57STeq+Q4vSSr0om/hE39W/EQA2TMwcZJhPpHiUQ0YH35MZn0MnF90QIOQG+kQhm2/6jBLTphh8aP/KxThD6mqmlZZQxphgiVDSKXW6rQfCYI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773166035; c=relaxed/simple; bh=a1Pvg4yZGhrB7Ad+3Lps8sXbKD3gaB6p/V9/wVlSryE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UVBuvgPMSuzgmKZVQ2fmGS4BvQ6Gm3tU+OgpETsLW7e5pb7OHRCTtT9ua2Usv17EVnjZN/lYFyTpc4M2tMW15BQFLhilLah1WvBBjbl4neu0VKCniomHcpXE3NV0LcWcmKaKAsyekUvqi8fPlKWLYjYxxpVplInW/Cr4iAV48W0= 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=IOcaMiQO; 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="IOcaMiQO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773166033; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XGYykbg+OoPSVrBuSLqw+hISIdL4nGnaMw8Q0N/GNyc=; b=IOcaMiQOgF+qcn76jHg1klgeS1iCcFydtnHj8v00kd/9Vz4Kt5sM4d/6eZbnvSxRGPUM7u J6WTswNR/omelRYax+p8wwXxwCeeT6qKAQKlz63S4vCY5QNW/GVs/V9X0l6UO4xmbDZYHU WNgI5GoyjqUHoIf68ayI+5n+0aElfus= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-357-O2SzThmCOQKKxDcn1RdvDg-1; Tue, 10 Mar 2026 14:07:07 -0400 X-MC-Unique: O2SzThmCOQKKxDcn1RdvDg-1 X-Mimecast-MFC-AGG-ID: O2SzThmCOQKKxDcn1RdvDg_1773166026 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8695118002CD; Tue, 10 Mar 2026 18:07:05 +0000 (UTC) Received: from my-developer-toolbox-latest (unknown [10.2.16.255]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id ED368180075C; Tue, 10 Mar 2026 18:07:02 +0000 (UTC) Date: Tue, 10 Mar 2026 11:07:01 -0700 From: Chris Leech To: yunje shin Cc: Hannes Reinecke , Keith Busch , Chaitanya Kulkarni , Sagi Grimberg , Christoph Hellwig , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, ioerts@kookmin.ac.kr Subject: Re: [PATCH] nvmet: auth: validate dhchap id list lengths(KASAN: slab-out-of-bounds) Message-ID: <20260310-ladle-underuse-50f571ba519c@redhat.com> References: <20260211065925.2878336-1-ioerts@kookmin.ac.kr> <20260309-scalding-propeller-e00bf0af6519@redhat.com> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 On Wed, Mar 11, 2026 at 02:52:36AM +0900, yunje shin wrote: > Thanks for the review. > > Yes, I triggered the KASAN issue by injecting an invalid dhlen The > reproduction steps are: > 1. Connect to the NVMe/TCP target on port 4420 (ICReq + Fabrics CONNECT). > 2. Send AUTH_SEND with a crafted NEGOTIATE payload where dhlen=200. 3. > The kernel target code in nvmet_auth_negotiate() then iterates > > for (i = 0; i < data->auth_protocol[0].dhchap.dhlen; i++) { > int tmp_dhgid = data->auth_protocol[0].dhchap.idlist[i + 30]; > > With dhlen=200, this reads idlist[30..229], but idlist[] is only 60 > bytes (indices 0..59). The accesses at indices 60 and beyond read past > the kmalloc'd slab object into adjacent slab memory, which KASAN > catches as a slab-out-of-bounds read. Thank you, I appreciate understanding how this was triggered. > While the standard Linux NVMe host driver does use hardcoded halen=3 > and dhlen=6, the NVMe target is network-facing and must validate all > fields from the wire. A malicious or non-standard host can send > arbitrary values. The same applies to halen — if halen > 30, the > first loop also reads out of bounds. Yes, this code absolutly should validate halen and dhlen bounds. > Regarding idlist_half — yes, idlist is currently a fixed 60-byte array > and the DH offset is always 30. I derived it from sizeof(idlist) > rather than hardcoding 30 so that the bounds check and the DH offset > stay consistent with the array definition. If the struct ever changes, > the validation adapts automatically instead of silently going stale. The 60-byte idlist (and 30:30 split) are part of the NVMe specification. It's the maximum amount of space while keeping to a 64-byte struct. I'd rather see this made clearer with a define for the limit, but not adding code that appears to calculate it at runtime. Thanks, - Chris