From patchwork Tue Aug 8 15:16:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1818657 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=PV0vfnxw; 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=idaWwfqU; 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 4RKxcw63zNz1yYl for ; Wed, 9 Aug 2023 01:17:20 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTORd-0008J4-WD; Tue, 08 Aug 2023 11:16:26 -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 1qTORc-0008HJ-1j; Tue, 08 Aug 2023 11:16:24 -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 1qTORZ-0000nK-O0; Tue, 08 Aug 2023 11:16:23 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id D68653200313; Tue, 8 Aug 2023 11:16:18 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 08 Aug 2023 11:16:19 -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=1691507778; x= 1691594178; bh=utIErE0zSRQECiJRKxegToY8hT7jxZDHY6ToNXDSHT0=; b=P V0vfnxwc118QxkL/zR7zbJ0RYlblHBhCdoIAVmpdI81URgAUH1NyPgCk3VeI3JSt kcK8ltDwADq0SzqSNMvy2hBuSV5ZNzTW5+YNi8AoQvBobxzg8z2W63zJF/cRE2kG 1QzjnvmPdE1CJtfZTsHrmHwmCoTsRVAj01i3ooEwxtos9/bALah2hKLLAn/w2ANi aQXEwXRX8bvaM0jUInjmlqYYzqe5OgI0vVEkXbU9Icgd72CG5XzeWrOW8ryfRpXV Ssb8tqtgcHrwWaO28cIfUeInr99MMLLOur6BbZ13WElUMgdO1AJBGasJPy7fVUvJ FuCz/okePbZaIOxdeXdNw== 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=1691507778; x= 1691594178; bh=utIErE0zSRQECiJRKxegToY8hT7jxZDHY6ToNXDSHT0=; b=i daWwfqUs3Fe4zVOts8IAshykFqve2qLV2471tEkCT7yc8gBMH9e/RwvYiUm0qUv4 d6JwIORAo3pyDgh4/N4C3CdQ2EJMsEokHtVHm1pAUiZKz8A6Cu/g0Y9ojkK0p5wR ZvTaxA/Yplnch4Q+lUlX32RX53qeqnF5JqQ4QhUcAySirEfQc9fkVefI/GMhQlBX jSPGHaHa0QjHjAdWei4kLDwZk/zOnj/lTYmzPHDb3C3nGQLQhL/TFzzC0Nv49eB2 15N+C/xObx4XOleBU0ldq4ZDb9qzgIvIpCodik9lX5pJoSuPWQleBOmJ/rC5GFe0 nyyadXtSauZpv86dWpYsA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrledvgdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeefheetgeehffefgeekgffhgeeijeekveffhfejveefkeduieeiveehteeludej udenucffohhmrghinhepghhithhlrggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepihhtshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 8 Aug 2023 11:16:17 -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 1/2] hw/nvme: fix null pointer access in directive receive Date: Tue, 8 Aug 2023 17:16:13 +0200 Message-ID: <20230808151611.81933-5-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=1116; i=k.jensen@samsung.com; h=from:subject; bh=j+NXBa/MMLYk3DAJYgmXBjwSLj9vOoizgsNljLeNsQo=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGTSXDvoFpMdDmuwaGu2FDyWDR/d/iE7ReVKy d+P2ntJ4I+HdokBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJk0lw7AAoJEE3hrzFt Tw3pgjoH/2QTQ3WtHqaSM4VIhTAlj/sXnU+bj2DV0mmfEiMZvkbKtjTux1h+UjjI5BEhz3V6qJz 4FXdycOsIolXOWcm4UlOnCW3Am/egdlZNXt/UoBs0KKqP/+RhqVbs6HgOL2oNdNH2ryQLXaiLUD fFo/7dZXhNKtfCpTIsSE53Rm00I+7W5p0sDVtsweJxAtZCEBc2+kFSciJCip8y2OCjxYOXMXifb ui3+qM3+SyQxwSWaM80eP7AYaUC6oZJUuJpyA6w0K6Irlua4TaHzyiAAjuXYqxAJySXTrZTeOEb sQFnZN0j5wzliOK+qdwGsLsmR6UyN//QPOmzcjVMVJXMYPxms6lMAKjt 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 nvme_directive_receive() does not check if an endurance group has been configured (set) prior to testing if flexible data placement is enabled or not. Fix this. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1815 Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation") Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index d217ae91b506..e5b5c7034d2b 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -6900,7 +6900,7 @@ static uint16_t nvme_directive_receive(NvmeCtrl *n, NvmeRequest *req) case NVME_DIRECTIVE_IDENTIFY: switch (doper) { case NVME_DIRECTIVE_RETURN_PARAMS: - if (ns->endgrp->fdp.enabled) { + if (ns->endgrp && ns->endgrp->fdp.enabled) { id.supported |= 1 << NVME_DIRECTIVE_DATA_PLACEMENT; id.enabled |= 1 << NVME_DIRECTIVE_DATA_PLACEMENT; id.persistent |= 1 << NVME_DIRECTIVE_DATA_PLACEMENT; 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;