virtio-balloon: fix buffer overflow in memory stats feature
PATCH 1/1 virtio-balloon: fix buffer overflow in memory stats feature
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.
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.
--- hw/virtio/virtio-balloon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio-balloon.c +1 -1
@@ -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 ); }
Signature · 1 line
1.9.3
Quoted 4 lines · Luiz Capitulino
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_tvariable.
s/manipuled/manipulated/
Quoted 16 lines
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 <[email protected]>--- hw/virtio/virtio-balloon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/virtio/virtio-balloon.c +0
-0
hw/virtio/virtio-balloon.c static void balloon_stats_destroy_timer(VirtIOBalloon *s) · line 92
Quoted 7 lines
hw/virtio/virtio-balloon.c +1
-1@@ -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?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 27 lines · On Mon, 15 Sep 2014 13:16:01 -0600 Eric Blake <[email protected]> wrote:
Quoted 4 lines · Luiz Capitulino
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_tvariable.s/manipuled/manipulated/
Quoted 19 lines
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 <[email protected]>--- hw/virtio/virtio-balloon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/virtio/virtio-balloon.c +0
-0@@ -87,7 +87,7 @@ static void balloon_stats_destroy_timer(VirtIOBalloon *s) } }
Quoted 7 lines
hw/virtio/virtio-balloon.c static void balloon_stats_destroy_timer(VirtIOBalloon *s) · line 92
Quoted 4 lines
hw/virtio/virtio-balloon.c +1
-1-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 :)
Quoted 11 lines · Luiz Capitulino
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_tvariable.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 <[email protected]>
Subject claims buffer overflow, but description suggests integer overflow. Which one is it?
[...]
Quoted 10 lines · On Tue, 16 Sep 2014 09:25:02 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 8 lines · Luiz Capitulino
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_tvariable.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.
Quoted 6 lines
Quoted 3 lines
Fix it.
Signed-off-by Luiz Capitulino <[email protected]>Subject claims buffer overflow, but description suggests integer overflow. Which one is it?
Integer.
Quoted 13 lines · Luiz Capitulino
Quoted 10 lines · On Tue, 16 Sep 2014 09:25:02 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 8 lines · Luiz Capitulino
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_tvariable.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.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Fix it.
Signed-off-by Luiz Capitulino <[email protected]>Subject claims buffer overflow, but description suggests integer overflow. Which one is it?
Integer.
Thanks. If you fix the subject, you can add my R-by.
Quoted 17 lines · On Tue, 16 Sep 2014 15:43:14 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 15 lines · Luiz Capitulino
Quoted 12 lines · On Tue, 16 Sep 2014 09:25:02 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 10 lines · Luiz Capitulino
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_tvariable.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.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Luiz Capitulino <[email protected]>Subject claims buffer overflow, but description suggests integer overflow. Which one is it?
Integer.
Thanks. If you fix the subject, you can add my R-by.
I've fixed the subject, but I've also added a new hunk to the patch.