From patchwork Tue Aug 8 15:16:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1818658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm2 header.b=VT66vm3j; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=Rr103s5+; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RKxdF5CT4z1yYl for ; Wed, 9 Aug 2023 01:17:37 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTORh-0008L2-3C; Tue, 08 Aug 2023 11:16:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qTORe-0008Jl-Tt; Tue, 08 Aug 2023 11:16:27 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qTORd-0000oS-4I; Tue, 08 Aug 2023 11:16:26 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 8640C3200312; Tue, 8 Aug 2023 11:16:22 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 08 Aug 2023 11:16:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1691507782; x= 1691594182; bh=rx1eiDCVgW8lKg4tPT9pJHpMKFAyLXbF9hzf+QCdfG4=; b=V T66vm3jrwdvqpl0LJ2mJuWSaz21PaR9JO/eclzSKnDaxB0iZHy+1vgRwUYzP0CnM r25ACoRtEyUMm8s6IOpq7scrKiAWB+xB80vQZ6twYxnLiR5keDgadG+rIO3tUK5V 6b3ivK/0K55Px4YsCNMtzRTZRcfH53rR0eaC+KWliUVx2XOwu3VqzVxmi7LZeD3H rYKu5G4OjfGDofSQXjv5qMFAWdy1Xv+iIB5KRlAX2yixNsWKA9SwBSJj9UdLDakc Rgk6ooyMAej77Az5EwrVjMw5EzQnltcdTHhScnimWqdSJ6mNaFu/UHrN5rQRGzZp l8IPrlWnxQ7PxZa2RYA3g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1691507782; x= 1691594182; bh=rx1eiDCVgW8lKg4tPT9pJHpMKFAyLXbF9hzf+QCdfG4=; b=R r103s5+vRQSL/KncSkKNPXylRWAp7p6/heeEWtBe6ZpnaHLjfqTDxYAUvmXq08Ve ZI4m6H7yJMqRJIxq1gP+eijThj2N8Ci5x+cs1dNVlNHM6lJqmDtrNfaF2mnvaJn+ qK0zXttJ3je9LMd0bo4/klsAj15W08gahDTDtZPp1PXXkaLahb2dF99Hn5CJE81s E+STLYAgXyaRb3ZjLENYxLTM7qhiO/8nwafv6CSiIO9XuTjMPi1BFmrp/kUB63SX bdF08HSH8qwWSwAg4UmnqsFnmD9wwBi3vLRJQ5yVmQ8JZQUyFOJoStugOxiiR1y7 lSZehL5wzCMxu1NfwGvQQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrledvgdekiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedujedu geenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehith hssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 8 Aug 2023 11:16:19 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: Keith Busch , Jesper Devantier , Klaus Jensen , qemu-block@nongnu.org, Klaus Jensen , qemu-stable@nongnu.org Subject: [PATCH 2/2] hw/nvme: fix null pointer access in ruh update Date: Tue, 8 Aug 2023 17:16:14 +0200 Message-ID: <20230808151611.81933-6-its@irrelevant.dk> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230808151611.81933-4-its@irrelevant.dk> References: <20230808151611.81933-4-its@irrelevant.dk> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1150; i=k.jensen@samsung.com; h=from:subject; bh=r3EYdS4UbRYsXmJqdIzqatd4x/HJs6EmFk4hqmRzQLk=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGTSXDsXGqdt3OCZIUt2Rh1tkj2oJjfYiIJBK 0QL/ccb6YHOzIkBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJk0lw7AAoJEE3hrzFt Tw3pNMEH/2+m9wO1J1abqtWDBkRtS3DnPXUnv/pJ8dMN8FgeBycGHE6VM/KZVPk1Ybw1DBXoKCc n99kRMvfl8IX3dmnc0i0olCoHwHw71+6+uxFc/KK3e4rWQ8oJtRBcq9V+nuCSZleiIpUUqjzw6W HtAyQJWgcDSy+6gHqIsw81tInKrZDP9hzLq6xiEJBPa2MLOe/f/Ss3TOBD9vb3bX89rFwpflRxP DnL4ALfwqeDMz4tIJzWk00Y+yVKvyirtsXD5Jh1S9r+DdQyVExW8X/f6Gq72AH5cdvvGqicvuMt FG2uKdwyA4xM7bKwZsl005iBDotOc/+XJa+T+4wFo/YBU3btPRbRrKlM X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-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, 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: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Klaus Jensen The Reclaim Unit Update operation in I/O Management Receive does not verify the presence of a configured endurance group prior to accessing it. Fix this. Cc: qemu-stable@nongnu.org Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation") Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index e5b5c7034d2b..539d27355313 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -4361,7 +4361,13 @@ static uint16_t nvme_io_mgmt_send_ruh_update(NvmeCtrl *n, NvmeRequest *req) uint32_t npid = (cdw10 >> 1) + 1; unsigned int i = 0; g_autofree uint16_t *pids = NULL; - uint32_t maxnpid = n->subsys->endgrp.fdp.nrg * n->subsys->endgrp.fdp.nruh; + uint32_t maxnpid; + + if (!ns->endgrp || !ns->endgrp->fdp.enabled) { + return NVME_FDP_DISABLED | NVME_DNR; + } + + maxnpid = n->subsys->endgrp.fdp.nrg * n->subsys->endgrp.fdp.nruh; if (unlikely(npid >= MIN(NVME_FDP_MAXPIDS, maxnpid))) { return NVME_INVALID_FIELD | NVME_DNR;