diff mbox

[24/39] ivshmem: check shm isn't already initialized

Message ID 1435330185-23248-25-git-send-email-marcandre.lureau@gmail.com
State New
Headers show

Commit Message

Marc-André Lureau June 26, 2015, 2:49 p.m. UTC
The server should not be allowed to change the shm, this isn't handled
by qemu (perhaps it could be though).

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
---
 hw/misc/ivshmem.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox

Patch

diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 9085f7c..b8167d9 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -534,6 +534,12 @@  static void ivshmem_read(void *opaque, const uint8_t *buf, int size)
     if (incoming_posn == -1) {
         void * map_ptr;
 
+        if (s->shm_fd >= 0) {
+            error_report("shm already initialized");
+            close(incoming_fd);
+            return;
+        }
+
         if (check_shm_size(s, incoming_fd, &err) == -1) {
             error_report_err(err);
             close(incoming_fd);