From: David Gibson <david@gibson.dropbear.id.au>
To: Avi Kivity <avi@redhat.com>
Cc: agraf@suse.de, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Fix subtle integer overflow bug in memory API
Date: Fri, 16 Sep 2011 13:16:17 +1000 [thread overview]
Message-ID: <20110916031617.GA9025@yookeroo.fritz.box> (raw)
In-Reply-To: <4E71A92A.3080701@redhat.com>
On Thu, Sep 15, 2011 at 10:28:42AM +0300, Avi Kivity wrote:
> On 09/15/2011 05:58 AM, David Gibson wrote:
> >> Well.. I'm pretty sure that particular case can no longer be
> >> triggered. But there may be other integer overflow bugs in this code,
> >> though I didn't spot them at a glance.
> >
> >Actually, there definitely are. addrrange_end() should probably be
> >redefined as the inclusive end, rather than the exclusive end, and
> >computed as:
> >
> > (start + size - 1)< start ? INT64_MAX : start + size - 1
> >
> >Hrm, except that that doesn't handle zero size ranges. And gets a bit
> >weird for INT64_MAX sized regions.
> >
> >Hrm, yeah, these really should be changed to use unsigneds.
> >
>
> Unsigneds don't work because we sometimes subtract values and get
> into the negative area, due to aliases.
I realise that, but I'm fairly confident the order of calculations can
be adjusted to cope with those cases, just as we can cope with the
overflow cases with care.
Remember that because unsigned overflow is defined, and we can use
that in some cases.
> We're using values that are close to the end of the 63 or 64 bit
> range and playing with them. Overflow is always close and we'll
> always be able to find a way to defeat the code (even if it doesn't
> occur in practice). I'm tempted to declare that the memory API
> supports only 60 bits of address space (and
> s/INT64_MAX/MEMORY_REGION_SIZE_MAX/), that gives us a few levels of
> wild offsetting before we get confused.
There is something to be said for that. Although many systems have
theoretical 64-bit addressing, on powerpc at least, the biggest
actually implemented physical address bus I'm aware of is under 50
bits.
Of course, there could be some highly sparse intermediate bus
addressing schemes which screw that up.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
next prev parent reply other threads:[~2011-09-16 3:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-14 7:02 [Qemu-devel] [PATCH] Fix subtle integer overflow bug in memory API David Gibson
2011-09-14 8:23 ` Avi Kivity
2011-09-14 8:38 ` Avi Kivity
2011-09-15 2:34 ` David Gibson
2011-09-15 2:58 ` David Gibson
2011-09-15 7:28 ` Avi Kivity
2011-09-16 3:16 ` David Gibson [this message]
2011-09-15 7:38 ` Paolo Bonzini
2011-09-15 7:43 ` Avi Kivity
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=20110916031617.GA9025@yookeroo.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=avi@redhat.com \
--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).