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.133.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 6B73F28D8D1 for ; Tue, 10 Mar 2026 20:47:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773175643; cv=none; b=BIcFPpPZVUjyfwYeKXVtUq3juI+iM21di0IVJ12Qaw26XHzi4rb3WGce2382r7tv9U2hoAw1mwC6amhaHFFVP6O5nojekzFbJYmwY0Sj+Sp6KcqPCWqYLEL6emPB0Hbgi3P6cA9Nu9QV/uQK9gBXkLd518wPayTCeucvBxsNhlA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773175643; c=relaxed/simple; bh=19Svzjwfhym7UQ4RwABLY5Xi/trw/UvoJB2XHV30H2I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XolV9kznVNk3nyPhjQslo4LN/LHVvTs7C3aOQ5ChKdI91b1u+mUN30yvoQJtSqOJQQ90/dqJOyODjOhIBn8ySn78vrMymycSIsaEQq7XFHtIZrYSdUxEpXh9Tjen6te9dwtFN5cS1BGWbGCarhOSVDroeiwkabkTJV9YV+fWd4Q= 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=M46ouYwE; arc=none smtp.client-ip=170.10.133.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="M46ouYwE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773175641; 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=ph8h7Z3c42DjREBZqPAGzIBfE7ES/TtS9+NAaOI9FsU=; b=M46ouYwERgUGrbjEIRE8kDqXe4772U/zcerls2htGr7bs/4wYyxa24mk8PwWzc+TrO9amE zlG5q9E6VCLI+NTD1PZMdJWRLiwV5Htupv/yel1gVIR7BwJWe6xz0fqgBjZZd2z+MJXpnz /SS/zgy9GgdECuxK+IATHItQBLiz3bw= 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-452-cXEsoc7_P_KZxh4XoI7n5Q-1; Tue, 10 Mar 2026 16:47:17 -0400 X-MC-Unique: cXEsoc7_P_KZxh4XoI7n5Q-1 X-Mimecast-MFC-AGG-ID: cXEsoc7_P_KZxh4XoI7n5Q_1773175635 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 D5725195608E; Tue, 10 Mar 2026 20:47:14 +0000 (UTC) Received: from my-developer-toolbox-latest (unknown [10.2.16.255]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 9064D3000223; Tue, 10 Mar 2026 20:47:12 +0000 (UTC) Date: Tue, 10 Mar 2026 13:47:11 -0700 From: Chris Leech To: YunJe Shin Cc: hch@lst.de, 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 Subject: Re: [PATCH v2] nvmet-auth: validate negotiate payload length(BUG: KASAN: slab-out-of-bounds) Message-ID: <20260310-video-foyer-58fbf3080e9b@redhat.com> References: <20260211160859.GA11869@lst.de> <20260212013338.1417091-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: <20260212013338.1417091-1-ioerts@kookmin.ac.kr> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 On Thu, Feb 12, 2026 at 10:33:18AM +0900, YunJe Shin wrote: > From: Yunje Shin > > AUTH_SEND negotiation requires at least one DH-HMAC-CHAP protocol descriptor. > 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+0x1d24/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 > --- > 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(-) > ... > + size_t min_len = struct_size(neg, auth_protocol, 1); Maybe this could have been struct_size(neg, auth_protocol, neg->napd)? But the target code also enforces napd == 1, so it ends up being the same. Reviewed-by: Chris Leech