From patchwork Mon Nov 6 15:32:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 741412 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp1152003wrr; Mon, 6 Nov 2023 07:34:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkoGR+qi9MmhzE/wYrArdaR8UXy59bh2uQ3keSJEwuHu6koN95JjAEKgQe5x6zvS717Gc5 X-Received: by 2002:a05:6102:1042:b0:45d:91b2:99c7 with SMTP id h2-20020a056102104200b0045d91b299c7mr7636435vsq.32.1699284875738; Mon, 06 Nov 2023 07:34:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699284875; cv=none; d=google.com; s=arc-20160816; b=b4eLfeRuT7cDsOvISDZApdfuC8kh0Bjd4w4pG6t/nBT1QgnojKeMvv3jvl5suXCDDJ 3uAx9N7CW9h6ZtA4JXxlGJjcPNQCraDFbW73GvFAJaJBJXQQxM3dFot3O3NCSNW7Feh4 AFJu9LDmlUnEhBflHIccnRJNbSenuclsWAghtiLU+Qne46OXm4KDwegKmOva4McYDVzB 8oQtp/ZxdLc/dzfzPnfnPCYx2RUD4hmUqU/lKB+LkRTEuWtZHkHYBxOaW5sIoVaD6LcF fGApGXdpL4XyxlCe5tddXhF2fT/tnk+Jk6YQA1865oc933pV7Go9t6FnNpXiNDAarK8F wRCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=nlNPCN/IoODLnyMcuMdcFvSi7ZKXsxk62aEPG2/TY9M=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=HtGZOLfVts+f6/BWY6BMLgxoymKDEe/YdhRXFcJmpvw7yvhXEHco7JR4Lg1hrgAduY qA7BKMkphR0lk6e0dyM5yEXr79fsXB9t1NbAUHH/F/mxYra5Mk9sXYGKKOcdHjCVoA5A 7sdz+VJMoQ6V2z2DgVMxbP0LSJ8B7mQvttHj6Prd4fi/EquCWgvdE0ok28r9QTih6fXq NKfhtUMFZsCB03rfNkkosEQWzQg0mOuSJkKbauB3zU1Vm1BuxEVfVJKFq440LyEApDON WbSqTegr7+ocqFD1EcTQ5/zQ1XCqdrfIn9F0QeOqpYfFPrg+noFSfPS5XkD6qAkI1nqV GYCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ObA0z+6v; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 7-20020ac85907000000b0041092f38eeasi5622599qty.434.2023.11.06.07.34.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Nov 2023 07:34:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ObA0z+6v; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r01bB-00009G-Fh; Mon, 06 Nov 2023 10:33:09 -0500 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 1r01aw-00082P-PW for qemu-devel@nongnu.org; Mon, 06 Nov 2023 10:32:57 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r01am-0004O4-Of for qemu-devel@nongnu.org; Mon, 06 Nov 2023 10:32:52 -0500 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-32d834ec222so2395881f8f.0 for ; Mon, 06 Nov 2023 07:32:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699284763; x=1699889563; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=nlNPCN/IoODLnyMcuMdcFvSi7ZKXsxk62aEPG2/TY9M=; b=ObA0z+6v0qdVJvh9S15f0K34nasikDNEw/JTvjtfFsz/xnCdQwrE29B4D+UcYERInC S2eqflDceoT5I6vN86JQkBSwZNnKipXjKGqPfFOcuG9XLhyez1Bz7X/0VSw6H8w9qLcj LmWSyphX2FmSqX608Bl2OLmtc0z1f70hmYCki7t61tphsmkMHCrouLswYuSOh87t4Hs2 bzgQfKl2LV92I2mXGBGrSbK7eODpFQRVimM3MOlca7QjXB7s4yuYhFPBQwlzIczYRG5x f9NozbuqYF0onFx/oGq/oClDUnAGHvNe7KtIv1yMbekGjj56DpOKYt9vOXQ/6fDWc6t3 0s0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699284763; x=1699889563; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nlNPCN/IoODLnyMcuMdcFvSi7ZKXsxk62aEPG2/TY9M=; b=KYl+7/2djtXFJ4nzhEzlTPu9u4EB7kAU4fZiO1Wet/TDDbkhh8gS/a0K2AzWjXGjJv rW2cXXufjhBFLhZZ3p5dcrcYcAK9C8KX+Mf7quXOrnWcJiJWEOP3SiKbmDCuVwUd9PJB EO9MlQQb5Wtmp/lkcG22uS6yMO6oDZJgAuxOxf09FhwSZRf3V7rRNA/GQUlDKERsg0IE GEGPJ14erfyOEpzD4kHqSW+y7eTYyXJhGq19cp0gpDJX+ecUHXx04YSpgNr8EtlpWBoe B6nuiCvhHEUIWpDKe4Bb7p9NicD6LRAjPnFlev9Hane/weE7cH3kPAACN5/KJB4Jifqh h1wA== X-Gm-Message-State: AOJu0YxlYqad2k5ZSIEiakcA+lsAu21e2OYUzmKkcbKM4UNI+OWHjgvh EWj18mWDClpENrUySRZV5ZBo13cB/nbH6+9N0qY= X-Received: by 2002:a05:6000:178e:b0:32f:8d4a:efa8 with SMTP id e14-20020a056000178e00b0032f8d4aefa8mr18920746wrg.23.1699284763144; Mon, 06 Nov 2023 07:32:43 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id d5-20020adff2c5000000b0032da6f17ffdsm9752176wrp.38.2023.11.06.07.32.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 07:32:42 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 08/12] block/nvme: nvme_process_completion() fix bound for cid Date: Mon, 6 Nov 2023 15:32:34 +0000 Message-Id: <20231106153238.1426649-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106153238.1426649-1-peter.maydell@linaro.org> References: <20231106153238.1426649-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Vladimir Sementsov-Ogievskiy NVMeQueuePair::reqs has length NVME_NUM_REQS, which less than NVME_QUEUE_SIZE by 1. Fixes: 1086e95da17050 ("block/nvme: switch to a NVMeRequest freelist") Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi Reviewed-by: Maksim Davydov Message-id: 20231017125941.810461-5-vsementsov@yandex-team.ru Signed-off-by: Peter Maydell --- block/nvme.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 96b3f8f2fa1..0a0a0a6b36c 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -417,9 +417,10 @@ static bool nvme_process_completion(NVMeQueuePair *q) q->cq_phase = !q->cq_phase; } cid = le16_to_cpu(c->cid); - if (cid == 0 || cid > NVME_QUEUE_SIZE) { - warn_report("NVMe: Unexpected CID in completion queue: %"PRIu32", " - "queue size: %u", cid, NVME_QUEUE_SIZE); + if (cid == 0 || cid > NVME_NUM_REQS) { + warn_report("NVMe: Unexpected CID in completion queue: %" PRIu32 + ", should be within: 1..%u inclusively", cid, + NVME_NUM_REQS); continue; } trace_nvme_complete_command(s, q->index, cid);