From patchwork Wed Jun 28 09:24:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1800925 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=fm1 header.b=Lql5oL57; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=R0N35L4x; 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 4QrbnD21Rxz20ZV for ; Wed, 28 Jun 2023 19:26:40 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qERQJ-0006vV-MW; Wed, 28 Jun 2023 05:25:15 -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 1qERQI-0006u0-Fj; Wed, 28 Jun 2023 05:25:14 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qERQH-0001Ll-0R; Wed, 28 Jun 2023 05:25:14 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 262ED5C0241; Wed, 28 Jun 2023 05:25:12 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 28 Jun 2023 05:25:12 -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=fm1; t=1687944312; x= 1688030712; bh=jIrNQjCeIfQAQMFuWqOGIuTcnSKlPmEGEl2PPVtk0HM=; b=L ql5oL57sG9NscJAZKs1IExCMhiay3wLT7zPqDV/WNuMMtLQODjXscU9HraEEW0VD JCgcUbqwYbqoeC/c73ysn4kw+hbArVQeArmZScg7nR4/JKK1MRrQQENfjfHJOPjt DzcWWPJnBg7aaR2wP46HGnCzGGQtQsR2p6PEHk76OQZ9cA3XWE+scIwDyxRoOq0W MDKXf2UwsDv7pEGJuluoXPGo7/kKjswP44lro1q63Jm8QAvPEL2ylMkdl4DR1niG PfxQXMzliJir+ysDAp/TMlrhoMZdFT9X2/fjWpZ3CsRtx9lnAKe7y2pKl4Ka41+g dfDXoTDgZ4Rtc6CJiavtw== 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=fm2; t=1687944312; x= 1688030712; bh=jIrNQjCeIfQAQMFuWqOGIuTcnSKlPmEGEl2PPVtk0HM=; b=R 0N35L4xgzDv/gt+HWr+ce3udSeDXw20JHCJyllx/nJZYe7bOysJdXTDzZ+oXWLuQ GHBRcqiij07+a3rnTZzeDoSuGByjxp79NirsYte1IwQKX934mbCNAjwOiUe4GFrh AgfBGhU3DvNT3/FuRvIJuRYF5ICNwWZ3BP+3lrW3usyyxqMUlK6wQFOMiFpjzAo8 54yrAk+wk44BvAeKpmn6MqBqpp0+eAVsSqatJPJB6j9baBybzLixxQxIFtslk/KG 3YErCLw0t4Ov1ourKhnkT1iOvWJQddEMrrDP5v3PlVvnkxpekn/3CHiqCyn7lBPB 8E3PtB6oF5pUOyELGMA/Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrtddvgddugecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeejgfeilefgieevheekueevheehkeefveegiefgheefgfejjeehffefgedujedu geenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehith hssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Jun 2023 05:25:10 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org, Peter Maydell Cc: Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Keith Busch , =?utf-8?q?P?= =?utf-8?q?hilippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Hanna Reitz , Klaus Jensen , Klaus Jensen , Jesper Wendel Devantier Subject: [PULL 5/7] hw/nvme: verify uniqueness of reclaim unit handle identifiers Date: Wed, 28 Jun 2023 11:24:59 +0200 Message-ID: <20230628092453.39602-14-its@irrelevant.dk> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628092453.39602-9-its@irrelevant.dk> References: <20230628092453.39602-9-its@irrelevant.dk> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1070; i=k.jensen@samsung.com; h=from:subject; bh=3vltZ98tCm0E+zi8rOmVK306W6qCc37UtTzfMKwuHWw=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGSb/GZlVPZdBnHJlXT7sY1N/72wNPJRO93uF NTfauZ56FzUPIkBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJkm/xmAAoJEE3hrzFt Tw3p5o0H/1+2+uIvWmJHLqfu7A4HnLzL82rhLgrtEIcPZOYYBPtQGL6UmluubWwp143aPkmDXlj KuPty9xL+oRdRcDJJkdScJqS+BSwzXExVH2H2EYLYzc04dAbrAoWtCh2l2+w07O+0JFjOLdpxzr kvimQY/47tL8pQpoL/kMpzcKBc0BvXvxgopdfp0BSXfsv/T/9FnUckyxByMCttbkuyrT0YIwpxZ 4Npi9RmOENRJyPKpnBNJ17Yo8vXIfYzbL7QMDDnjCT++GwBj8rr+dJfFIilcBzMUORBIS8CjW7l b1nImCN7L9FdunKru1wqJrzVz15DZOwUCHWzJTskkYAEcDWbPxCdNarj X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 Verify that a reclaim unit handle identifier is only specified once in fdp.ruhs. Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation") Reviewed-by: Jesper Wendel Devantier Signed-off-by: Klaus Jensen --- hw/nvme/ns.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index 050fdaf50fcd..c4ea2033bb1c 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -453,6 +453,17 @@ static bool nvme_ns_init_fdp(NvmeNamespace *ns, Error **errp) free(r); + /* verify that the ruhids are unique */ + for (unsigned int i = 0; i < ns->fdp.nphs; i++) { + for (unsigned int j = i + 1; j < ns->fdp.nphs; j++) { + if (ruhids[i] == ruhids[j]) { + error_setg(errp, "duplicate reclaim unit handle identifier: %u", + ruhids[i]); + return false; + } + } + } + ph = ns->fdp.phs = g_new(uint16_t, ns->fdp.nphs); ruhid = ruhids;