From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: Akihiko Odaki <akihiko.odaki@daynix.com>,
qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
Alexander Bulekov <alxndr@bu.edu>
Subject: Re: [PATCH] hw/timer/hpet: Fix expiration time overflow
Date: Tue, 28 Feb 2023 07:57:44 -0500 [thread overview]
Message-ID: <20230228075717-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <73c73f7a-f182-7892-162f-daa9f39be45a@linaro.org>
On Mon, Jan 30, 2023 at 11:55:18PM +0100, Philippe Mathieu-Daudé wrote:
> On 30/1/23 14:50, Akihiko Odaki wrote:
> > The expiration time provided for timer_mod() can overflow if a
> > ridiculously large value is set to the comparator register. The
> > resulting value can represent a past time after rounded, forcing the
> > timer to fire immediately. If the timer is configured as periodic, it
> > will rearm the timer again, and form an endless loop.
> >
> > Check if the expiration value will overflow, and if it will, stop the
> > timer instead of rearming the timer with the overflowed time.
> >
> > This bug was found by Alexander Bulekov when fuzzing igb, a new
> > network device emulation:
> > https://patchew.org/QEMU/20230129053316.1071513-1-alxndr@bu.edu/
> >
> > The fixed test case is:
> > fuzz/crash_2d7036941dcda1ad4380bb8a9174ed0c949bcefd
> >
> > Fixes: 16b29ae180 ("Add HPET emulation to qemu (Beth Kon)")
> > Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> > ---
> > hw/timer/hpet.c | 19 +++++++++++++------
> > 1 file changed, 13 insertions(+), 6 deletions(-)
> >
> > diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
> > index 9520471be2..3657d5f463 100644
> > --- a/hw/timer/hpet.c
> > +++ b/hw/timer/hpet.c
> > @@ -352,6 +352,16 @@ static const VMStateDescription vmstate_hpet = {
> > }
> > };
> > +static void arm(HPETTimer *t, uint64_t ticks)
>
> Could we rename as hpet_[re]arm() similarly to this file's other helpers?
Akihiko Odaki, I expect there will be a new version of this?
> > +{
> > + if (ticks < ns_to_ticks(INT64_MAX / 2)) {
> > + timer_mod(t->qemu_timer,
> > + qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ticks_to_ns(ticks));
> > + } else {
> > + timer_del(t->qemu_timer);
> > + }
> > +}
next prev parent reply other threads:[~2023-02-28 12:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 13:50 [PATCH] hw/timer/hpet: Fix expiration time overflow Akihiko Odaki
2023-01-30 15:11 ` Michael S. Tsirkin
2023-01-30 22:55 ` Philippe Mathieu-Daudé
2023-02-28 12:57 ` Michael S. Tsirkin [this message]
2023-03-01 3:47 ` Akihiko Odaki
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=20230228075717-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=akihiko.odaki@daynix.com \
--cc=alxndr@bu.edu \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.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).