From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTc1a-0003wC-1S for qemu-devel@nongnu.org; Mon, 15 Sep 2014 15:33:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XTc1S-0000Yw-1Q for qemu-devel@nongnu.org; Mon, 15 Sep 2014 15:33:21 -0400 Date: Mon, 15 Sep 2014 15:33:06 -0400 From: Luiz Capitulino Message-ID: <20140915153306.2f610c3a@redhat.com> In-Reply-To: <54173AF1.7010301@redhat.com> References: <20140915140934.17c1bfea@redhat.com> <54173AF1.7010301@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] virtio-balloon: fix buffer overflow in memory stats feature List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel , qemu-stable@nongnu.org On Mon, 15 Sep 2014 13:16:01 -0600 Eric Blake wrote: > On 09/15/2014 12:09 PM, Luiz Capitulino wrote: > > When a QMP client changes the polling interval time by setting > > the guest-stats-polling-interval property, the interval value > > is stored and manipuled as an int64_t variable. > > > > s/manipuled/manipulated/ > > > However, the balloon_stats_change_timer() function, which is > > used to set the actual timer with the interval value, takes > > an int instead, causing an overflow for big interval values. > > > > Fix it. > > > > Signed-off-by: Luiz Capitulino > > --- > > hw/virtio/virtio-balloon.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c > > index 2c30b3d..9629264 100644 > > --- a/hw/virtio/virtio-balloon.c > > +++ b/hw/virtio/virtio-balloon.c > > @@ -87,7 +87,7 @@ static void balloon_stats_destroy_timer(VirtIOBalloon *s) > > } > > } > > > > -static void balloon_stats_change_timer(VirtIOBalloon *s, int secs) > > +static void balloon_stats_change_timer(VirtIOBalloon *s, int64_t secs) > > { > > timer_mod(s->stats_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + secs * 1000); > > secs * 1000 can still overflow for (really large) values, do we care > about that? Hmm, good point. I think I could keep the s/int/int64_t change but limit secs to UINT_MAX for simplicity. I guess we don't expect anyone to set this to billions of seconds in the future :)