From patchwork Tue Aug 1 21:54:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 708756 Delivered-To: patch@linaro.org Received: by 2002:a5d:55c5:0:b0:317:2194:b2bc with SMTP id i5csp575394wrw; Tue, 1 Aug 2023 14:56:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlFAWGW5S6I+EMaVtqWEZaQnv1FxpcpOzshwi2KZ0fOlnIZm5ouTjK4iceLEzeFF5dEbLJtG X-Received: by 2002:ac8:7c4d:0:b0:405:3806:4444 with SMTP id o13-20020ac87c4d000000b0040538064444mr19370627qtv.40.1690926992633; Tue, 01 Aug 2023 14:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690926992; cv=none; d=google.com; s=arc-20160816; b=za7fDtSouCqL/iG1CBXY0ZUeilTvSPRJKUYGEXOLupkusoSsz02sjrBiXalvU4Tuw9 qmMa2Di8ES9TuMwZW4QLliF4nhqSCcHEFi0SkNor3DEFErdlbiLtiPLFNrIYpdBSgyAk NTFRM49yW0hY2uIfCufeVSy7dh1teYsDAo3DCtkvwdQA+1AXjknGA81k5SdrtIohyXBS dwKOrw3EqZEVi9RWPpbxjoNWjoUt6gbf8mdRblINqFOShUV9orPRxdDbHkX/cYZV4Sao zTBRNvKvc7I4OhfpobgmG2KpaKJ7mcmyyLO8KuYm5VOFS/2uRqjJqTvFR55ItgIueA9F RvLw== 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=M3NPngvFxJx9HpwzOZ730KZECLvyMyLnhk8cJRf/tlQ=; fh=DDMVslwBuY3s0nfe5aVPvdWqk8Uk9pXilLas2gi731U=; b=u5xH8A47uCN3YIEHh9MbHFujDTlws1Uxe1KuJDUVpIa5Wy7HP8hzMHvs6chBvAVkXI IXrYfYfn5N7HeM3sqA8HroE66n2xcSq5OeDAwacjS/L9Q7PeGdVp7+V9/u/dNKtfXRiJ Bef7iLTm81vP9fA4E8fHZu8K48UrU/HOk7wXDI5eTaxLKnL8o5CQ6NltvHJtksyqgcxa gVmQv47OgNvMs48lg73XaYRmaCcCbSt1/aUIUUPgY4EQpyHPlVaWoG0uAf54SzqIZHiu ASzCU3OZ9i5sEB86w6Simag2dPTjadld+Azk6cChuFiitb8EVVXD6wP4mrmVqFwl3otP S6GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=apryb7d7; 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 x2-20020a05622a000200b00403b2b69cb5si7885372qtw.189.2023.08.01.14.56.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 Aug 2023 14:56: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=pass header.i=@linaro.org header.s=google header.b=apryb7d7; 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 1qQxKG-0003q1-6b; Tue, 01 Aug 2023 17:54:44 -0400 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 1qQxKE-0003o7-7z for qemu-devel@nongnu.org; Tue, 01 Aug 2023 17:54:42 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQxKB-0004lM-4M for qemu-devel@nongnu.org; Tue, 01 Aug 2023 17:54:41 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3128fcd58f3so6271986f8f.1 for ; Tue, 01 Aug 2023 14:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690926871; x=1691531671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M3NPngvFxJx9HpwzOZ730KZECLvyMyLnhk8cJRf/tlQ=; b=apryb7d7TxDShJHIY+cCaXy6JQwZXoBmrkwFMRLeIVv5FGc/Z7vuDLQyoRZHJfYzwU mG1ZRXx7wKOr6W08Qau6PZfxMnyys0O5lQbTfRfJBlipPuo0Kq4af6HECNSbRTlH0A0F y1KfYOw+ne3DcnWcImcZkglzs3XFoQ6WNA5aq2GajzovthldW9QXCF5Fj3V5u/WCND0a 3Lxirv69YrJ58DjnY9SP3g2Opw/7KXbxvLjqY+rQ77Ob5+q8ZPOpIkxmyQGo+9hp1WHU ZIIH8fVbLcQQxgpJa7Wc8C4xRXuBPRYHXedfakq904pvRFLsMCZ1TDzkmV+Vj8BW+/Gd 9f1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690926871; x=1691531671; 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:message-id:reply-to; bh=M3NPngvFxJx9HpwzOZ730KZECLvyMyLnhk8cJRf/tlQ=; b=U4quWa171+w69vI+zoDY3WZ/N9NKhivhjVQy4soMu66U3792S3HAM+uilGpfLCVmhE Uqww47RNZD+wRnGNLbhXQTE/4Al/cw3Bp9QxbdDLjNWU/S3Q4wwC1Ypaxq7XhDra4Exn 2M/k3oh/8QlWzMoALSjya1hWIo+PtAXtZZ8h3+rq0gDGQ8kpaRKSAspv/3lUUr4ti/f0 rMUoOT1ajgOe1xAOWE+4vQimuQlDWLcaJSMjxs0DMfhw3h8pGr6Z3BHlLQ+lIWPOwISc /GUTiQI3m7EkqNU6fe5Bs9NibsJkwISg5QelsUAldhCqWjYQ/w4jtVQrvmY5QUV65XCd z2cQ== X-Gm-Message-State: ABy/qLZkO+0oyupeyQ/0rIDjm8iuDurzIrMvyjcgiH4+2F/nOnpR1YNv hKfRLzeQ5YxW3NgdiM/+uzunFJPz4FyaWolougw= X-Received: by 2002:adf:f204:0:b0:314:12c:4322 with SMTP id p4-20020adff204000000b00314012c4322mr3323325wro.4.1690926871535; Tue, 01 Aug 2023 14:54:31 -0700 (PDT) Received: from localhost.localdomain ([176.176.174.59]) by smtp.gmail.com with ESMTPSA id m12-20020adff38c000000b00313f031876esm17181934wro.43.2023.08.01.14.54.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 01 Aug 2023 14:54:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, qemu-s390x@nongnu.org, David Woodhouse , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 01/10] hw/xen: fix off-by-one in xen_evtchn_set_gsi() Date: Tue, 1 Aug 2023 23:54:12 +0200 Message-Id: <20230801215421.60133-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230801215421.60133-1-philmd@linaro.org> References: <20230801215421.60133-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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=unavailable 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: David Woodhouse Coverity points out (CID 1508128) a bounds checking error. We need to check for gsi >= IOAPIC_NUM_PINS, not just greater-than. Also fix up an assert() that has the same problem, that Coverity didn't see. Fixes: 4f81baa33ed6 ("hw/xen: Support GSI mapping to PIRQ") Signed-off-by: David Woodhouse Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230801175747.145906-2-dwmw2@infradead.org> Signed-off-by: Philippe Mathieu-Daudé --- hw/i386/kvm/xen_evtchn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c index 3d810dbd59..0e9c108614 100644 --- a/hw/i386/kvm/xen_evtchn.c +++ b/hw/i386/kvm/xen_evtchn.c @@ -1587,7 +1587,7 @@ static int allocate_pirq(XenEvtchnState *s, int type, int gsi) found: pirq_inuse_word(s, pirq) |= pirq_inuse_bit(pirq); if (gsi >= 0) { - assert(gsi <= IOAPIC_NUM_PINS); + assert(gsi < IOAPIC_NUM_PINS); s->gsi_pirq[gsi] = pirq; } s->pirq[pirq].gsi = gsi; @@ -1601,7 +1601,7 @@ bool xen_evtchn_set_gsi(int gsi, int level) assert(qemu_mutex_iothread_locked()); - if (!s || gsi < 0 || gsi > IOAPIC_NUM_PINS) { + if (!s || gsi < 0 || gsi >= IOAPIC_NUM_PINS) { return false; }