From patchwork Wed Sep 21 16:07:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 607961 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2488435pvb; Wed, 21 Sep 2022 09:29:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6H2D6TgubysUQBXqPBcxoJ8wQiTE1OImk33qw1nBYa+ls7f5p0m7i0H3kXbXxBztDP8Xhs X-Received: by 2002:a05:620a:2989:b0:6ce:1913:83ce with SMTP id r9-20020a05620a298900b006ce191383cemr20493232qkp.49.1663777752687; Wed, 21 Sep 2022 09:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663777752; cv=none; d=google.com; s=arc-20160816; b=fWbV8k46Ge7S7sjn3S///j0CQ90UTpqZi9XrYWWwpUBQIq/o5ujRXv95V3hSi06fe0 r0ims6bvTFuuDj+cnIt8tWGdEFiwwR+ShlT9zrg1sCEshhNj2BgoT2aau4EpB0EC8Lpi jMl0bTeswInWAj+LNhp7lS5omBY27Pl8MAS+LpC+Hu2dI00bCkUQNLwlv/Yyfe4l/MwM t9z9utL7U10XGdtV+C3RFkVwGhrrblqwXquiAFPpCscOJ/jUUwwl7hp0zVqQbdqxgwSR ScXjCl+cN0RWxbptCai678afy/4Xm8IvJ+cllaVEGTS37Bk0hhf9eaNx0zsCos5LUKu4 JWyQ== 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:cc:to :from:dkim-signature; bh=8wlJEOjCIqrgKcd8hYGZEfi/YjXbLCd9HqD3SSKCejY=; b=ePnVhtr01f5taGqFg3BqduoQL8TIRxjx00Llnue1mJSSz6XsQwwDwfrEwB212XdE9l 1+FqTMHruGrqL+qjrI6HbLo184t2GaiBXYiHatb+/jOPblxQk/1T9JVFI3/p9SIGVV4o bL/R4ZhYkm7mDXWS98CWhR31JvNRe5MlKKD7FkEISYeIFWcxpWAcwqgjg5rz+9+w5DGi 858hJZsD0ahonEftdl3i0kXCwmsbxw77hYipqPUTZ8HS62ZvfIPG7jULcCIwR/SMLEoN ljTPvT65mlbpntvR2rV8TzW4hes4gB8usuTU/fKT2ITs3aLKoSW3fVpxGZJ3NjvAVAv3 hJBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nKSVH8n+; 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 2-20020ac85742000000b0035ced04659asi1955733qtx.718.2022.09.21.09.29.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Sep 2022 09:29:12 -0700 (PDT) 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=nKSVH8n+; 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]:34240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ob2b2-0002lC-7n for patch@linaro.org; Wed, 21 Sep 2022 12:29:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ob2Gp-0003To-LI for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:20 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:38556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ob2Gm-0000bz-Ih for qemu-devel@nongnu.org; Wed, 21 Sep 2022 12:08:19 -0400 Received: by mail-wm1-x336.google.com with SMTP id h130-20020a1c2188000000b003b4cadadce7so8115821wmh.3 for ; Wed, 21 Sep 2022 09:08:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=8wlJEOjCIqrgKcd8hYGZEfi/YjXbLCd9HqD3SSKCejY=; b=nKSVH8n+7fIS3nSDQq/+9YSUxw/54UBP8h4BuTs6AG8M1y0aXsVm1dArRdtwS1fo7u rXPu6O38uN0hlb1LRd8J9Q6aXMhU9Ka1d+DJhI8ykyXoyz4zntoAXXfEbZEguqeQ1vSc CykwOdaK99lDsk+FSq6to6/dogKFNCrs7TFTuAcCP/uMamlWRgcngwb/l3MCNulq0H6m 4Ma1n5RriNgWVqPkUkUmGTTIHY4cQILpUC6CZ3uD21gDN1CDyLrSbJHAFM1Clk6HYJI9 THPD6lT3XKy85lrUq+lsiOUD2+BYnIT/11LiOB5fBE77u8fIDwF6XwF8zcFd8IXQ5e8I rTUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=8wlJEOjCIqrgKcd8hYGZEfi/YjXbLCd9HqD3SSKCejY=; b=a0X5U5qHMYDsNFmqdz81ess82nEHGYV5zUsJE8cpxFNGEEnuM0pkUBizu5fwnS7r7i xT+ZFRXd/Z63LlU3NBOn/4iOYrMb8q1uExG/qWFs7jUu6oBpuOp/bpUWKhigJKZAwTFe 4P/mZh4JHKWWxfhWXfJY2HSMAWxC0I/h+UxLzcJUhixwMzThbscydxrGATfaJlQ0ZJD4 Kh6uLe+IkMOsYVQNsw4lVMQeeOv9Vot25sRMpHYbM17dnMZlkw1fZobNHzmkqbFGmIWb +OoH20eo+MuU+UgjWZfUzmQij4WeZt2nbhaediLfR6yERG+1KmKJyNZqZo9h/BnnROG0 haxA== X-Gm-Message-State: ACrzQf2QwGeaW3KEqfOkzP4qIpiFK2c3oawJjjEWPSad1TO2TkrkBBaW l0MY55X9D0LG6fPQ48RGYm1bEw== X-Received: by 2002:a05:600c:4e0a:b0:3b4:91fe:80e3 with SMTP id b10-20020a05600c4e0a00b003b491fe80e3mr6449775wmq.91.1663776495707; Wed, 21 Sep 2022 09:08:15 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id iv14-20020a05600c548e00b003b435c41103sm4800673wmb.0.2022.09.21.09.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 09:08:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B7F221FFBE; Wed, 21 Sep 2022 17:08:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: minyihh@uci.edu, ma.mandourr@gmail.com, Luke.Craig@ll.mit.edu, cota@braap.org, aaron@os.amperecomputing.com, kuhn.chenqun@huawei.com, robhenry@microsoft.com, mahmoudabdalghany@outlook.com, Richard Henderson , Damien Hedde , =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss Subject: [PATCH v1 06/10] plugins: Assert mmu_idx in range before use in qemu_plugin_get_hwaddr Date: Wed, 21 Sep 2022 17:07:57 +0100 Message-Id: <20220921160801.1490125-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921160801.1490125-1-alex.bennee@linaro.org> References: <20220921160801.1490125-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.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 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" From: Richard Henderson Coverity reports out-of-bound accesses here. This should be a false positive due to how the index is decoded from MemOpIdx. Fixes: Coverity CID 1487201 Signed-off-by: Richard Henderson Reviewed-by: Damien Hedde Message-Id: <20220401190233.329360-1-richard.henderson@linaro.org> Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- plugins/api.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/api.c b/plugins/api.c index 7bf71b189d..2078b16edb 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -289,6 +289,8 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, enum qemu_plugin_mem_rw rw = get_plugin_meminfo_rw(info); hwaddr_info.is_store = (rw & QEMU_PLUGIN_MEM_W) != 0; + assert(mmu_idx < NB_MMU_MODES); + if (!tlb_plugin_lookup(cpu, vaddr, mmu_idx, hwaddr_info.is_store, &hwaddr_info)) { error_report("invalid use of qemu_plugin_get_hwaddr");