From patchwork Fri Apr 8 16:47:41 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: 558857 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp501335map; Fri, 8 Apr 2022 09:59:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDRaurB4obT4JIHJs8rFVtmt5kLoR+mLSVoRnyOfU+5MByUE7OevcdVRsHPbl8phI7UBe2 X-Received: by 2002:a05:6902:13c1:b0:61d:969c:109c with SMTP id y1-20020a05690213c100b0061d969c109cmr14674298ybu.133.1649437172507; Fri, 08 Apr 2022 09:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649437172; cv=none; d=google.com; s=arc-20160816; b=ENkqBCn3L8TTCzrxD6MrbbuG1dvNCM/suxjNOpByN6QdoSsh9NwQuKxK++xbb9dKp8 cZ8QC9Oq0ZYmBJRsNVtvhUIay45F4b8Y5PXapfLxoKLLw19Ch0HJbNjiQde4083aGieF TJyjjSgux4y4l8+7Lc4gYKrcw1mXuqBBn03DuxlPBd9QzLOwPfryqGoPRrlzBCuQQsnS rSUkmw0LKcyot++CNk6hUI29ugKSQQHfrGTFz0YSw7pLBXh9oH36WIHWuTnII8+qYVsB abvUBVVYCkpJDFk8Vdsfj3j9JC0wJd9sdJ1+Z9zNRuFBTOjIFpwfxIeYhtHD4Od0UdpU gyug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=KFP0HbJwpn4b/8mC3zm1M94yL+pYYUEsnbWxKZ7xRO4=; b=cMCeGOeBsBr3UKmbMawDqpNEWjTjH/W96q+GaqpnsHxpcrRE23TQ/RzGUBXfhjKD4C UyF5de+Ue1kNuHWiQufs6SScM2MO0MxqyiHeGyJXsx2jiw10vt0zPKuzJi95G4dOBEBW JrtX65IKg07nv30/jYh/SyvxJO7LpGQe2ssgXBM15c6kek5E147ciZEPqu8uq7w1L2LI 5+DPNV6osLTBkw1lw8QBPdY2qyM1A/wuWVbyd+XVWgnl19uRKsCtaBGhMwP7OhFJjyLe kJmA82oXn25Tfucm4LEfCvEgUcEmT38vJpRxLmbDM5PtNvBEyoa5pJqtp/bwXx2E+tBs 2QXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="w2Bx6K/B"; 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=fail (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 z8-20020a81d408000000b002e5da2c72aesi765115ywi.487.2022.04.08.09.59.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Apr 2022 09:59:32 -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=fail header.i=@linaro.org header.s=google header.b="w2Bx6K/B"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:46942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ncrxM-0004P3-1k for patch@linaro.org; Fri, 08 Apr 2022 12:59:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncrsq-0008Is-KK for qemu-devel@nongnu.org; Fri, 08 Apr 2022 12:54:52 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:37752) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ncrsp-0003ub-3l for qemu-devel@nongnu.org; Fri, 08 Apr 2022 12:54:52 -0400 Received: by mail-ed1-x52b.google.com with SMTP id b15so10747380edn.4 for ; Fri, 08 Apr 2022 09:54:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KFP0HbJwpn4b/8mC3zm1M94yL+pYYUEsnbWxKZ7xRO4=; b=w2Bx6K/BdmJ1ra+KbuXMj2STD1KouuvTD4HoMkk/yXNNX3N8aLuQPsO4YFyav47CI1 JC//EQ1VwseGzJdmx+t6a0uUfCYhwajdNzggyuxKxk1ELCVVdYQxqnDHuc7I+6k8n6Xi 4iPxpLpDPzGnla51HvFWfBknyGT7jagS+glMDTokVX/ckMlhih9Xw4LpfliYULpCy2dc +V/sUYSXxNWYY5NNheKivWk6KBhsx4fapwHW64e0R1JGecSyyDrgoZyMAYIsJMUAXPBP Bjk46hSsGT3QkqTX48TMdO+J8oIB1iNK1Z0jFAG+W9vomoqSt1Mt25bUXTX6536oCk09 cPyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KFP0HbJwpn4b/8mC3zm1M94yL+pYYUEsnbWxKZ7xRO4=; b=Il6SDk14BqTn/euyT2bph8MrIblUo37bclYjxRNVmDImnAcASU9X5iswyqpdA020EO x4HXyRU3/I+urKfzj6tcyUdUhz1TIsbpoeXoDa5zt4Umw9RCzEDBygdyOl6BHDnYFmsM C36ymR5QUmi7b6fAKlAyM42FCRbYMqiCjWdPlw9hGkbOJWs/g4IX1cRU1p8ZSk2dC2D9 O/daKJh9ER+ydeI50UB8g3u/eV/a3+JLGra5hpKM8oZjRE92brhhcVnerIUcRYrOvusV EWVpkfxMQVP0nl4ilOLo1lkyxU0fnGYw75V5CH2uDGtc1NDTIQvxMLWL06pODsZb5Qag 99Hg== X-Gm-Message-State: AOAM533PrC9KJgj0NrR8xZ7UHqLgytrVOlk3tExFbvyeN/awzREWCBHx uQjgftWk+xOeUNV+zWV2jqK2+Q== X-Received: by 2002:a05:6402:26d0:b0:419:75eb:b3a with SMTP id x16-20020a05640226d000b0041975eb0b3amr20744011edd.0.1649436889750; Fri, 08 Apr 2022 09:54:49 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f2-20020a170906390200b006e7f5fedbe7sm5336427eje.3.2022.04.08.09.54.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 09:54:43 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 97FCD1FFBA; Fri, 8 Apr 2022 17:47:45 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 14/15] plugins: Assert mmu_idx in range before use in qemu_plugin_get_hwaddr Date: Fri, 8 Apr 2022 17:47:41 +0100 Message-Id: <20220408164742.2844631-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220408164742.2844631-1-alex.bennee@linaro.org> References: <20220408164742.2844631-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52b.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: , Cc: fam@euphon.net, Damien Hedde , berrange@redhat.com, stefanha@redhat.com, crosa@redhat.com, Richard Henderson , aaron@os.amperecomputing.com, robhenry@microsoft.com, f4bug@amsat.org, mahmoudabdalghany@outlook.com, minyihh@uci.edu, cota@braap.org, Luke.Craig@ll.mit.edu, pbonzini@redhat.com, kuhn.chenqun@huawei.com, ma.mandourr@gmail.com, Alexandre Iooss , =?utf-8?q?Alex_?= =?utf-8?q?Benn=C3=A9e?= , aurelien@aurel32.net 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 --- 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");