* [Qemu-devel] [for 2.9] balloon: Don't balloon roms
@ 2016-12-16 11:41 Dr. David Alan Gilbert (git)
2016-12-16 12:25 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-12-16 11:41 UTC (permalink / raw)
To: qemu-devel, mst, pbonzini; +Cc: lcapitulino
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
A broken guest can specify physical addresses that correspond
to any memory region, but it shouldn't be able to change ROM.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
hw/virtio/trace-events | 2 ++
hw/virtio/virtio-balloon.c | 7 ++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
index 7b6f55e..6926eed 100644
--- a/hw/virtio/trace-events
+++ b/hw/virtio/trace-events
@@ -15,6 +15,8 @@ virtio_rng_pushed(void *rng, size_t len) "rng %p: %zd bytes pushed"
virtio_rng_request(void *rng, size_t size, unsigned quota) "rng %p: %zd bytes requested, %u bytes quota left"
# hw/virtio/virtio-balloon.c
+#
+virtio_balloon_bad_addr(uint64_t gpa) "%"PRIx64
virtio_balloon_handle_output(const char *name, uint64_t gpa) "section name: %s gpa: %"PRIx64
virtio_balloon_get_config(uint32_t num_pages, uint32_t actual) "num_pages: %d actual: %d"
virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d oldactual: %d"
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 884570a..a705e0e 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -228,8 +228,13 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq)
/* FIXME: remove get_system_memory(), but how? */
section = memory_region_find(get_system_memory(), pa, 1);
- if (!int128_nz(section.size) || !memory_region_is_ram(section.mr))
+ if (!int128_nz(section.size) ||
+ !memory_region_is_ram(section.mr) ||
+ memory_region_is_rom(section.mr) ||
+ memory_region_is_romd(section.mr)) {
+ trace_virtio_balloon_bad_addr(pa);
continue;
+ }
trace_virtio_balloon_handle_output(memory_region_name(section.mr),
pa);
--
2.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [for 2.9] balloon: Don't balloon roms
2016-12-16 11:41 [Qemu-devel] [for 2.9] balloon: Don't balloon roms Dr. David Alan Gilbert (git)
@ 2016-12-16 12:25 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2016-12-16 12:25 UTC (permalink / raw)
To: Dr. David Alan Gilbert (git), qemu-devel, mst; +Cc: lcapitulino, qemu-stable
On 16/12/2016 12:41, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> A broken guest can specify physical addresses that correspond
> to any memory region, but it shouldn't be able to change ROM.
>
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
> hw/virtio/trace-events | 2 ++
> hw/virtio/virtio-balloon.c | 7 ++++++-
> 2 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
> index 7b6f55e..6926eed 100644
> --- a/hw/virtio/trace-events
> +++ b/hw/virtio/trace-events
> @@ -15,6 +15,8 @@ virtio_rng_pushed(void *rng, size_t len) "rng %p: %zd bytes pushed"
> virtio_rng_request(void *rng, size_t size, unsigned quota) "rng %p: %zd bytes requested, %u bytes quota left"
>
> # hw/virtio/virtio-balloon.c
> +#
> +virtio_balloon_bad_addr(uint64_t gpa) "%"PRIx64
> virtio_balloon_handle_output(const char *name, uint64_t gpa) "section name: %s gpa: %"PRIx64
> virtio_balloon_get_config(uint32_t num_pages, uint32_t actual) "num_pages: %d actual: %d"
> virtio_balloon_set_config(uint32_t actual, uint32_t oldactual) "actual: %d oldactual: %d"
> diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
> index 884570a..a705e0e 100644
> --- a/hw/virtio/virtio-balloon.c
> +++ b/hw/virtio/virtio-balloon.c
> @@ -228,8 +228,13 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq)
>
> /* FIXME: remove get_system_memory(), but how? */
> section = memory_region_find(get_system_memory(), pa, 1);
> - if (!int128_nz(section.size) || !memory_region_is_ram(section.mr))
> + if (!int128_nz(section.size) ||
> + !memory_region_is_ram(section.mr) ||
> + memory_region_is_rom(section.mr) ||
> + memory_region_is_romd(section.mr)) {
> + trace_virtio_balloon_bad_addr(pa);
> continue;
> + }
>
> trace_virtio_balloon_handle_output(memory_region_name(section.mr),
> pa);
>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-stable@nongnu.org
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-16 12:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-16 11:41 [Qemu-devel] [for 2.9] balloon: Don't balloon roms Dr. David Alan Gilbert (git)
2016-12-16 12:25 ` Paolo Bonzini
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).