From nobody Wed Apr 16 14:11:16 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1641576723; cv=none; d=zohomail.com; s=zohoarc; b=IgicjAbAMgx08WnelqOnI/HzmVYyCKZlpg/G7PpVY4O7yyGdISalQenbPRF7JW8uN6fkR2R0UMIAqCEgSAen0u1mtVdQz3IHIZZx1L/+t8uE2MeOzAPuIvE4DXwzTYf4Z1/birgUZBXfZUEdcLQ0ZIsZiwauavjVx4C261n9jOw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641576723; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3lysZ/JZGCb/W/vOgl/A8X+COK6e6bD0XOz6b5zqsvo=; b=n8leQNie3eiU2uRfoTSbs8/9pPu2S7DHQhUxSg8mowh3XD793MbhjtJ3oihhaGglx3pnAXLPuT19wUE+Xxli+mT3C1rHmrFnCPpCcUYTMV9C4F8KRjktc14/9eujqd+uKiqM6+jLf82vYIqgigQyJgOrYtyP3lC3llJQX8RKykM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641576723733870.1975570792775; Fri, 7 Jan 2022 09:32:03 -0800 (PST) Received: from localhost ([::1]:60764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5t5u-00039Y-NZ for importer@patchew.org; Fri, 07 Jan 2022 12:32:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5sw2-000554-4I for qemu-devel@nongnu.org; Fri, 07 Jan 2022 12:21:50 -0500 Received: from [2a00:1450:4864:20::332] (port=46630 helo=mail-wm1-x332.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n5sw0-0007sN-LB for qemu-devel@nongnu.org; Fri, 07 Jan 2022 12:21:49 -0500 Received: by mail-wm1-x332.google.com with SMTP id d187-20020a1c1dc4000000b003474b4b7ebcso2628878wmd.5 for ; Fri, 07 Jan 2022 09:21:47 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id i6sm6060219wrf.79.2022.01.07.09.21.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 09:21:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3lysZ/JZGCb/W/vOgl/A8X+COK6e6bD0XOz6b5zqsvo=; b=BNGaJOMmOPpu4gfzJDediJ0AqsvJbC1LzNZr2rPZAUE+UyHBnJj35eqHOnxu2rFcGD fww27ar51yS7PO5I5TwRn0v9sScuvZOdsvMXwK4KVkstmUoOsZQFDpw9TrrNWSNLS7pN OQAKv65KqkGe/bp2k/azraXvwqek8GIUcN7YHL/ayjJnsN9UULitl4sAPBx1PAYEbbt/ tnUdLiSJWWJ48jOdA6LtVxPH189VVnDkDRIfKzvecgh3Lon9idnGycbsM8+TwvrqpTBG C7PPEGRle0hpfpl/olIbktigUMFWQJ3oQwoQlde+g+uZVZxb9b1ild+Boz9YToDi7NAU UMng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3lysZ/JZGCb/W/vOgl/A8X+COK6e6bD0XOz6b5zqsvo=; b=SWBg/J8CQrvPqyjnPK6cKkTYEIZtrTkaQmxOBublZTxnGWDqS8e1yGzPn8Wf/oJfRl 031CYTqN6A5OMR9dGhUEDYQQIU0lDuKE0iAcLTRsumOmwK5TZvgOuhYdPdRtPR2JFm5j HzQdCDWkCz0JjIJe6Jd1Q36CW4xYnLZ17VlYfIUt/i1xzL7JRbkhIzWntJe8LJ60SxIw p6VwC7Zm5I+niavAICc/xgvlXg79mwwabhsgPPfOyBS4rZtlhtxcq8p+rcSMW7IDrkHk 5/C+AqHOgCr/9whR0CThU5rs+MOo1xnz3L6vJWglqJ8oTCrgYXj5sDRT4TYRs7J1XNeZ IC2A== X-Gm-Message-State: AOAM533Mt1pME0fcsEDtKl1s3cQ8c1GIEfNPCRpa3s+1xI4h8Buh6oFP 4+DP0sy8n1qsNrwJOTssSCSVMz0iTlSlAg== X-Google-Smtp-Source: ABdhPJx2TVSMYEgLM6aFX/JWLy9FyScJzEDX1hilai8NeoU+rMm+soZHfQYXEUawWLU7oKyeGddSzw== X-Received: by 2002:a7b:c0ce:: with SMTP id s14mr11971621wmh.135.1641576106493; Fri, 07 Jan 2022 09:21:46 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 03/19] hw/intc/arm_gicv3_its: Correct off-by-one bounds check on rdbase Date: Fri, 7 Jan 2022 17:21:26 +0000 Message-Id: <20220107172142.2651911-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220107172142.2651911-1-peter.maydell@linaro.org> References: <20220107172142.2651911-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::332 (failed) 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=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1641576725330100002 The checks in the ITS on the rdbase values in guest commands are off-by-one: they permit the guest to pass us a value equal to s->gicv3->num_cpu, but the valid values are 0...num_cpu-1. This meant the guest could cause us to index off the end of the s->gicv3->cpu[] array when calling gicv3_redist_process_lpi(), and we would probably crash. (This is not a security bug, because this code is only usable with emulation, not with KVM.) Cc: qemu-stable@nongnu.org Fixes: 17fb5e36aabd4b ("hw/intc: GICv3 redistributor ITS processing") Signed-off-by: Peter Maydell Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- hw/intc/arm_gicv3_its.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c index b99e63d58f7..677b96dfe23 100644 --- a/hw/intc/arm_gicv3_its.c +++ b/hw/intc/arm_gicv3_its.c @@ -311,7 +311,7 @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t = value, uint32_t offset, */ rdbase =3D (cte & GITS_CTE_RDBASE_PROCNUM_MASK) >> 1U; =20 - if (rdbase > s->gicv3->num_cpu) { + if (rdbase >=3D s->gicv3->num_cpu) { return result; } =20 @@ -505,7 +505,7 @@ static bool process_mapc(GICv3ITSState *s, uint32_t off= set) =20 valid =3D (value & CMD_FIELD_VALID_MASK); =20 - if ((icid > s->ct.maxids.max_collids) || (rdbase > s->gicv3->num_cpu))= { + if ((icid > s->ct.maxids.max_collids) || (rdbase >=3D s->gicv3->num_cp= u)) { qemu_log_mask(LOG_GUEST_ERROR, "ITS MAPC: invalid collection table attributes " "icid %d rdbase %" PRIu64 "\n", icid, rdbase); --=20 2.25.1