Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4AE0606B02E for ; Wed, 4 Nov 2026 17:30:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=qnXR0H4F; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Qxc/lKac DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:content-type: Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=16E8qCGF5utYug4nc8pXJ5Iz2TbpJwf4zqjILINW+Uc=; b=qnXR0H4F6FBwfbCXnMqhtcYpcb 4KKiMa+ciHICUIGihbyB7QeR1b/NfFddxlZld3UXeMkRNgQ1Ec7YnAvGtMw/HwW9RkNMVUn/ZVabI 9jRdIjITekeoB69G10UVDTzWp22JliJUpQRXcWiIJsKkNVz651RvKc5fuaDq9d9eLPmweetHNsjUa PyS6dJLiPUo8Kjn8n+PlekoKGJK/cG/Qx0Qbgs9icLNmeoitVqFtIpuMB03r2qCNRRUyIcrcLdf5b 7aTMcgUj2UCUJH+O72IzKdje9+ODAK2AO7DYCn8ShWDuYVkiekLhw6Bf6N0FuK3LRTgDvCUBBo/+N HWkT1iDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xOeoV-00000006DdC-0h05; Wed, 04 Nov 2026 17:30:19 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xOeoR-00000006DaW-0LoA for linux-nvme@lists.infradead.org; Wed, 04 Nov 2026 17:30:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793813413; 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; bh=16E8qCGF5utYug4nc8pXJ5Iz2TbpJwf4zqjILINW+Uc=; b=Qxc/lKacZzILwMM9KBGkv1Ocw22JBaF6CdBdv1xJEVBpm934s871hIMh61XQPz66OxLXEr inhj0v+ppGFLvdka/abrswKoWi9CaD/JzhPCkQNVCGGTfp7EshxShW7MiuFORxeeMAzSBn Te/FVX9GhySqamaLIE2xMTKnhAcAEaI= Received: from mx-prod-mc-03.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-241-mmrO35lTOJ6QOlczo5YR_Q-1; Wed, 04 Nov 2026 12:28:37 -0500 X-MC-Unique: mmrO35lTOJ6QOlczo5YR_Q-1 X-Mimecast-MFC-AGG-ID: mmrO35lTOJ6QOlczo5YR_Q_1793813316 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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 587CB1955F12; Wed, 4 Nov 2026 17:28:36 +0000 (UTC) Received: from emilne-na.ibmlowe.csb (unknown [10.17.17.93]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 660031848D40; Wed, 4 Nov 2026 17:28:35 +0000 (UTC) From: "Ewan D. Milne" To: linux-nvme@lists.infradead.org Cc: kbusch@kernel.org, kch@nvidia.com, hch@lst.de, sagi@grimberg.me Subject: [PATCH] nvmet: don't return memory contents beyond valid data when reading ANA log page Date: Wed, 4 Nov 2026 12:28:33 -0500 Message-ID: <20261104172833.161567-1-emilne@redhat.com> X-Archived-By: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 0VRYBucDsIXYIBZ1r8WYxMkOeyYVcLL8bLzdb9LWtSQ_1793813316 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261104_093015_199625_57BEA2AB X-CRM114-Status: GOOD ( 12.55 ) X-Spam-Score: 0.5 (/) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 The host side does not know how much valid data will be returned by the target so it will typically provide a buffer larger than the amount of valid data in the ANA log page. The memory allocation used by the target does not guarantee that prior kernel memory contents will not be returned past the end of the valid page data. Fix this to ensure that the SGL is zeroed before copying the data. Fixes: 72efd25dcf4f ("nvmet: add minimal ANA support") Cc: stable@vger.kernel.org Signed-off-by: Ewan D. Milne --- drivers/nvme/target/admin-cmd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index 26028be8fe4d..bfd5750da27b 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -543,6 +543,15 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req) u16 ngrps = 0; u16 status; + /* + * The header and one descriptor per enabled group are the only bytes + * written below; zero the whole transfer first so the unwritten tail + * does not leak stale kernel memory to the host. + */ + status = nvmet_zero_sgl(req, 0, req->transfer_len); + if (status) + goto out; + status = NVME_SC_INTERNAL; desc = kmalloc_flex(*desc, nsids, NVMET_MAX_NAMESPACES); if (!desc) -- 2.43.0