From nobody Sun Feb 8 14:18:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637156040771655.0303203846712; Wed, 17 Nov 2021 05:34:00 -0800 (PST) Received: from localhost ([::1]:45934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnL4R-0001wZ-2K for importer@patchew.org; Wed, 17 Nov 2021 08:33:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnKuc-00063Z-Ds; Wed, 17 Nov 2021 08:23:44 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:46681) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnKuZ-0002xl-LO; Wed, 17 Nov 2021 08:23:41 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id C44085C0180; Wed, 17 Nov 2021 08:23:37 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 17 Nov 2021 08:23:37 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 17 Nov 2021 08:23:36 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=fm1; bh=nkiuqszGgJsMzEQCWWDaSIsiha CyQaKhHN2sGp/IaMw=; b=HCCRxe69V1oH7UVMSC9+AteAAUzseQ0ckcykP0R04b SufH3gPRcZdXWaGt6MO94T6s+w3Bfs2t9FCcqdV/AZTCjKZB8pI6RBFevz2sQAQ2 JvG7Kjudl4DsABP8yO4QM2+OMys9VIFER+nEn1GFUAhvn1S/kMeDJj/Z12W51YoC TW3JgR6yXP5g8RFTn2DoH+8ta4728xH3SdEJRaZGmAQzvokXy0qu/2HLXO464kNF fqXi9f1N3KOPht0oAp5qiwDuvewPgM0+1PmKSQkUBhSNyLguwvzt2FF+rsahCZbu U+Dj7hIVF4In288sLXPXCib43yNVK4s2FGhHzwbPLgEw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=nkiuqs zGgJsMzEQCWWDaSIsihaCyQaKhHN2sGp/IaMw=; b=Zr1y1cv00rTxHaaVYm3+So NyAgklT6yluVnIrV/9Q0xo87wPVLv8CKMElCaXGlOBTIYIFvYr38Pp1tZHpzyJfH ox5GVHHwj+kn36Htb2hijEF6plRfh2Tjele8eXnNcgkc43nG7Fh5dvezY7+WCMKP 9v1ufszVEjnlmogEv1lm7pzYlE/s5hMJnAQRyVZWubj04qlg/tzWj454MwRsMa3w jcwB169ehCsk+DOwklHbgINKq9yGvCQPPqri6Nq/oOKPWhXBY8i3F8w8QgSmsFr3 CMQKkmXzsaqHod8copAMf8dp3dDhoLQoNFoH2s8MtOafLK+QUWya09eIsaaWL0Ow == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfeeggdegiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofggtgfgsehtkeertdertdejnecuhfhrohhmpefmlhgruhhsucfl vghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtthgvrh hnpefhgfdvtdetgffffefgveetgfeifefhvdejhfdvtdegffdvudfgledtudelueelhfen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehithhsse hirhhrvghlvghvrghnthdrughk X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org Subject: [PATCH for-6.2] hw/nvme: fix buffer overrun in nvme_changed_nslist (CVE-2021-3947) Date: Wed, 17 Nov 2021 14:23:35 +0100 Message-Id: <20211117132335.41850-1-its@irrelevant.dk> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.29; envelope-from=its@irrelevant.dk; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-block@nongnu.org, Klaus Jensen , qemu-stable@nongnu.org, Qiuhao Li , Keith Busch , Klaus Jensen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1637156043822100001 From: Klaus Jensen Fix missing offset verification. Cc: qemu-stable@nongnu.org Cc: Philippe Mathieu-Daud=C3=A9 Reported-by: Qiuhao Li Fixes: f432fdfa121 ("support changed namespace asynchronous event") Signed-off-by: Klaus Jensen Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Gaurav Kamathe --- Note: Since its so easy to mess this fix up, the log pages code could probably use a refactor - there is a lot of duplicated code as well and it's easy to miss a check like this. However, defer that for 7.0. hw/nvme/ctrl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 6a571d18cfae..5f573c417b3d 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -4168,6 +4168,11 @@ static uint16_t nvme_changed_nslist(NvmeCtrl *n, uin= t8_t rae, uint32_t buf_len, int i =3D 0; uint32_t nsid; =20 + if (off >=3D sizeof(nslist)) { + trace_pci_nvme_err_invalid_log_page_offset(off, sizeof(nslist)); + return NVME_INVALID_FIELD | NVME_DNR; + } + memset(nslist, 0x0, sizeof(nslist)); trans_len =3D MIN(sizeof(nslist) - off, buf_len); =20 --=20 2.34.0