Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1607597
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] virtio_balloon: prevent uninitialized variable use |
| Date | 2017-03-23 16:20 +0100 |
| Message-ID | <tocGS-3Wl-5@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
The latest gcc-7.0.1 snapshot reports a new warning:
virtio/virtio_balloon.c: In function 'update_balloon_stats':
virtio/virtio_balloon.c:258:26: error: 'events[2]' is used uninitialized in this function [-Werror=uninitialized]
virtio/virtio_balloon.c:260:26: error: 'events[3]' is used uninitialized in this function [-Werror=uninitialized]
virtio/virtio_balloon.c:261:56: error: 'events[18]' is used uninitialized in this function [-Werror=uninitialized]
virtio/virtio_balloon.c:262:56: error: 'events[17]' is used uninitialized in this function [-Werror=uninitialized]
This seems absolutely right, so we should add an extra check to
prevent copying uninitialized stack data into the statistics.
From all I can tell, this has been broken since the statistics code
was originally added in 2.6.34.
Fixes: 9564e138b1f6 ("virtio: Add memory statistics reporting to the balloon driver (V4)")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/virtio/virtio_balloon.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 4e1191508228..cd5c54e2003d 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -254,12 +254,14 @@ static void update_balloon_stats(struct virtio_balloon *vb)
available = si_mem_available();
+#ifdef CONFIG_VM_EVENT_COUNTERS
update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN,
pages_to_bytes(events[PSWPIN]));
update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_OUT,
pages_to_bytes(events[PSWPOUT]));
update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#endif
update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
pages_to_bytes(i.freeram));
update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMTOT,
--
2.9.0
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] virtio_balloon: prevent uninitialized variable use Arnd Bergmann <arnd@arndb.de> - 2017-03-23 16:20 +0100
Re: [PATCH] virtio_balloon: prevent uninitialized variable use David Hildenbrand <david@redhat.com> - 2017-03-24 19:40 +0100
Re: [PATCH] virtio_balloon: prevent uninitialized variable use Ladi Prosek <lprosek@redhat.com> - 2017-03-24 21:20 +0100
Re: [PATCH] virtio_balloon: prevent uninitialized variable use Arnd Bergmann <arnd@arndb.de> - 2017-03-24 21:50 +0100
Re: [PATCH] virtio_balloon: prevent uninitialized variable use "Michael S. Tsirkin" <mst@redhat.com> - 2017-03-24 22:00 +0100
Re: [PATCH] virtio_balloon: prevent uninitialized variable use Ladi Prosek <lprosek@redhat.com> - 2017-03-27 12:10 +0200
csiph-web