From: David Woodhouse <dwmw2@infradead.org>
To: qemu-devel@nongnu.org
Cc: "Paul Durrant" <paul@xen.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Marcelo Tosatti" <mtosatti@redhat.com>,
kvm@vger.kernel.org, "Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Anthony PERARD" <anthony.perard@citrix.com>,
"David Woodhouse" <dwmw@amazon.co.uk>
Subject: [PATCH for-8.1 1/3] hw/xen: fix off-by-one in xen_evtchn_set_gsi()
Date: Tue, 1 Aug 2023 18:57:45 +0100 [thread overview]
Message-ID: <20230801175747.145906-2-dwmw2@infradead.org> (raw)
In-Reply-To: <20230801175747.145906-1-dwmw2@infradead.org>
From: David Woodhouse <dwmw@amazon.co.uk>
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 <dwmw@amazon.co.uk>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
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;
}
--
2.40.1
next prev parent reply other threads:[~2023-08-01 17:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-01 17:57 [PATCH for-8.1] Misc Xen-on-KVM fixes David Woodhouse
2023-08-01 17:57 ` David Woodhouse [this message]
2023-08-01 17:57 ` [PATCH for-8.1 2/3] i386/xen: consistent locking around Xen singleshot timers David Woodhouse
2023-08-01 17:57 ` [PATCH for-8.1 3/3] hw/xen: prevent guest from binding loopback event channel to itself David Woodhouse
2023-08-01 21:46 ` [PATCH for-8.1] Misc Xen-on-KVM fixes Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230801175747.145906-2-dwmw2@infradead.org \
--to=dwmw2@infradead.org \
--cc=anthony.perard@citrix.com \
--cc=dwmw@amazon.co.uk \
--cc=eduardo@habkost.net \
--cc=kvm@vger.kernel.org \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).