[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 30/40] ivshmem: Tighten check of property "size"
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL v2 30/40] ivshmem: Tighten check of property "size" |
Date: |
Mon, 21 Mar 2016 21:43:53 +0100 |
If size_t is narrower than 64 bits, passing uint64_t ivshmem_size to
mmap() truncates. Reject such sizes.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
---
hw/misc/ivshmem.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 7b9e769..66c713e 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -87,7 +87,7 @@ typedef struct IVShmemState {
*/
MemoryRegion bar;
MemoryRegion ivshmem;
- uint64_t ivshmem_size; /* size of shared memory region */
+ size_t ivshmem_size; /* size of shared memory region */
uint32_t ivshmem_64bit;
Peer *peers;
@@ -361,7 +361,7 @@ static int check_shm_size(IVShmemState *s, int fd, Error
**errp)
if (s->ivshmem_size > buf.st_size) {
error_setg(errp, "Requested memory size greater"
- " than shared object size (%" PRIu64 " > %" PRIu64")",
+ " than shared object size (%zu > %" PRIu64")",
s->ivshmem_size, (uint64_t)buf.st_size);
return -1;
} else {
@@ -865,7 +865,8 @@ static void pci_ivshmem_realize(PCIDevice *dev, Error
**errp)
} else {
char *end;
int64_t size = qemu_strtosz(s->sizearg, &end);
- if (size < 0 || *end != '\0' || !is_power_of_2(size)) {
+ if (size < 0 || (size_t)size != size || *end != '\0'
+ || !is_power_of_2(size)) {
error_setg(errp, "Invalid size %s", s->sizearg);
return;
}
--
2.4.3
- [Qemu-devel] [PULL v2 03/40] ivshmem-server: Don't overload POSIX shmem and file name, (continued)
- [Qemu-devel] [PULL v2 03/40] ivshmem-server: Don't overload POSIX shmem and file name, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 19/40] ivshmem: Clean up MSI-X conditions, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 32/40] ivshmem: Simplify memory regions for BAR 2 (shared memory), Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 37/40] ivshmem: Clean up after the previous commit, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 26/40] ivshmem: Propagate errors through ivshmem_recv_setup(), Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 40/40] contrib/ivshmem-server: Print "not for production" warning, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 36/40] ivshmem: Split ivshmem-plain, ivshmem-doorbell off ivshmem, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 21/40] ivshmem: Assert interrupts are set up once, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 33/40] ivshmem: Inline check_shm_size() into its only caller, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 28/40] ivshmem: Drop the hackish test for UNIX domain chardev, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 30/40] ivshmem: Tighten check of property "size",
Markus Armbruster <=
- [Qemu-devel] [PULL v2 09/40] ivshmem-test: Improve test cases /ivshmem/server-*, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 23/40] ivshmem: Disentangle ivshmem_read(), Markus Armbruster, 2016/03/21
- Re: [Qemu-devel] [PULL v2 00/40] ivshmem: Fixes, cleanups, device model split, Peter Maydell, 2016/03/22