From patchwork Thu Jan 20 12:36:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 533564 Delivered-To: patch@linaro.org Received: by 2002:adf:f849:0:0:0:0:0 with SMTP id d9csp17066wrq; Thu, 20 Jan 2022 09:17:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAhesgkf/5BNOn7oF9B308ZMJlBOWn5nPPSVMonTBC/MFv562HMKGSsxiIx1w1/Eu0ZAy9 X-Received: by 2002:a1f:30d7:: with SMTP id w206mr15697337vkw.6.1642699050472; Thu, 20 Jan 2022 09:17:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642699050; cv=none; d=google.com; s=arc-20160816; b=jdFBMVDwEf5YqTLTCcJAcvSyH3Po8pfR7jBrSKGL+YVLpsqFz1TzfEdX5T2p+W3NGf F5lveLrPd+D4nsCi7hUqy4A5j61/jGoNDPidVWz+0hgZhKmf05TTP6bKcxo2Qr2sudax MamfwGRZ4SDVgTnPwcu4q+2FRpJi38/ZeXHwpGD07eCQckkpu3RgkxlOECJiAawwxEVU Q6Dn7dB60JcTS2WDDS0cQCIRh1CSqj/g+cmlBiOg5t5/9wn6InLPfHKnPcPMA9IB+Tzf lU8268qPzIgQkJH1ar4O32uIjs1cw6VIBU6mRInzGL8easmQWFU0OzzEhSHYXqHDA+RE iPGg== 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=3qi68VF3hKwj9nbfCNrptYY2Ss41PAcXZjjUY+w1vZ4=; b=yeyLOVFQNiTJJwu9W3gAKhzdmt99rvOfza5vKIrqwvmXiY2ME9pP1MS12gbPaDNGbx Q588149IGWXTd/c8bKrazcSvfCXAVr3Cc70/wVDcggFSy7CQclETwCNxKzBceUS+94Q/ E3vv/3n+Kf4ZuOO4EclwPIdRx7EvmdMYlE7Mi6zLRHEvVRHqdeqveLkrBltBHL3xLIoU w52RV5Xu7p0yxt6lTPo0IiLs+6+v3HCbTujeU1D+w7/QnD8eivBQ4edO8YuvtGunPTUV FKtFp5UsxqBeL23gjnaaAAsDOvCofyiif3dK6fR9xNNsYlwH+OaCPvEwJy9tczcoV53f QPGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nr1d250s; 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 k4si741730uab.118.2022.01.20.09.17.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Jan 2022 09:17:30 -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=Nr1d250s; 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]:44860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAb3w-0002G4-6Q for patch@linaro.org; Thu, 20 Jan 2022 12:17:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAWgy-0004bX-Nm for qemu-devel@nongnu.org; Thu, 20 Jan 2022 07:37:28 -0500 Received: from [2a00:1450:4864:20::32c] (port=40448 helo=mail-wm1-x32c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAWgw-0003P3-Bj for qemu-devel@nongnu.org; Thu, 20 Jan 2022 07:37:28 -0500 Received: by mail-wm1-x32c.google.com with SMTP id r9-20020a1c4409000000b0034e043aaac7so479775wma.5 for ; Thu, 20 Jan 2022 04:37:25 -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=3qi68VF3hKwj9nbfCNrptYY2Ss41PAcXZjjUY+w1vZ4=; b=Nr1d250sksAXzUjDDT4NjLpPyUtrvJjW7oK4iUUo8V2E7EKyIsOGvRxwHXl2w6nvsS 0l0gi1oiDqQqPPpGY6TS522dQO3C1m42vvsfQFwxnA5AqrVItsbKhrFrgoLmxolZgl2j cxQTLN5nhr6jhSxynpg4O0iZKR8IcKLWUoAHhSQxX0N7Y9ANw7V5G+sU2S4OmRI5BLVL YpJTUWfQbQg7RmMUHA4aOyo5JmlGK758s8Bj83ovGo4tWrkAF/0K4TFbL+FcFHBE7ya8 YW3t+xefFIoCZo6re50XxFcrrH35uoxFAGLWBZJS7KIof9hRvkQbw5nZKAMAgt05ATiJ sjlw== 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=3qi68VF3hKwj9nbfCNrptYY2Ss41PAcXZjjUY+w1vZ4=; b=VArJgqV8aE8ngyYjHeoLsgOFoT5w+eOfxtCYSSy9Rfd/6lqMHY1rew92bulRaDKSvg CL9STYCZrnqCOBveikRsyNdPqqyHadVPYNvYQm7gsw6s9JS9h9omsDoHX9KXwHqMgZIZ EaXoYSWs7+5oyehHC9VE/hK/EnmZLbJ7oCyMFrNarCAET4Mibc8EHkzDMy6asQSfKxsq 6erGpHsx2HLR4GiYMdDtaNprgsapqK1CL5cKWD33RIsefMb6DSXJSJw0WS8xHsFIC4fN aWsXf4n7Idp7+eTb11vNnb+YcoZUEdCUU9iq75UGY7+K6bu8PBLXkTdRuU1kVlHnOxsO bzhA== X-Gm-Message-State: AOAM531NlmYY1xj7yy8e4zxzqp+I7y2rz/wQGV5MUDXCQ0IupmPAaBCA TUDGuQnjNY8Wf0EU2yPQvwlTYBBL10uLrg== X-Received: by 2002:a05:600c:2048:: with SMTP id p8mr8728686wmg.119.1642682245128; Thu, 20 Jan 2022 04:37:25 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t8sm7993324wmq.43.2022.01.20.04.37.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 04:37:23 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 37/38] hw/intc/arm_gicv3_its: Range-check ICID before indexing into collection table Date: Thu, 20 Jan 2022 12:36:29 +0000 Message-Id: <20220120123630.267975-38-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220120123630.267975-1-peter.maydell@linaro.org> References: <20220120123630.267975-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32c (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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, PDS_HP_HELO_NORDNS=0.001, 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In process_its_cmd(), we read an ICID out of the interrupt table entry, and then use it as an index into the collection table. Add a check that it is within range for the collection table first. This check is not strictly necessary, because: * we range check the ICID from the guest before writing it into the interrupt table entry, so the the only way to get an out of range ICID in process_its_cmd() is if a badly-behaved guest is writing directly to the interrupt table memory * the collection table is in guest memory, so QEMU won't fall over if we read off the end of it However, it seems clearer to include the check. Signed-off-by: Peter Maydell Reviewed-by: Alex Bennée Message-id: 20220111171048.3545974-14-peter.maydell@linaro.org --- hw/intc/arm_gicv3_its.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c index ef6c0f55ff9..b2f6a8c7f00 100644 --- a/hw/intc/arm_gicv3_its.c +++ b/hw/intc/arm_gicv3_its.c @@ -299,6 +299,13 @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, return CMD_CONTINUE; } + if (icid >= s->ct.num_ids) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: invalid ICID 0x%x in ITE (table corrupted?)\n", + __func__, icid); + return CMD_CONTINUE; + } + cte_valid = get_cte(s, icid, &cte, &res); if (res != MEMTX_OK) { return CMD_STALL;