From: Michael S. Tsirkin Date: Thu, 3 Apr 2014 16:51:42 +0000 (+0300) Subject: vmstate: fix buffer overflow in target-arm/machine.c X-Git-Tag: qemu-xen-4.5.0-rc1^2~106 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=9c01a91c7b201bcb7de04603450c3c64a2475f69;p=qemu-upstream-4.5-testing.git vmstate: fix buffer overflow in target-arm/machine.c CVE-2013-4531 cpreg_vmstate_indexes is a VARRAY_INT32. A negative value for cpreg_vmstate_array_len will cause a buffer overflow. VMSTATE_INT32_LE was supposed to protect against this but doesn't because it doesn't validate that input is non-negative. Fix this macro to valide the value appropriately. The only other user of VMSTATE_INT32_LE doesn't ever use negative numbers so it doesn't care. Reported-by: Anthony Liguori Signed-off-by: Michael S. Tsirkin Signed-off-by: Juan Quintela (cherry picked from commit d2ef4b61fe6d33d2a5dcf100a9b9440de341ad62) Signed-off-by: Michael Roth --- diff --git a/vmstate.c b/vmstate.c index f01922818..dbb76665d 100644 --- a/vmstate.c +++ b/vmstate.c @@ -337,8 +337,9 @@ const VMStateInfo vmstate_info_int32_equal = { .put = put_int32, }; -/* 32 bit int. Check that the received value is less than or equal to - the one in the field */ +/* 32 bit int. Check that the received value is non-negative + * and less than or equal to the one in the field. + */ static int get_int32_le(QEMUFile *f, void *pv, size_t size) { @@ -346,7 +347,7 @@ static int get_int32_le(QEMUFile *f, void *pv, size_t size) int32_t loaded; qemu_get_sbe32s(f, &loaded); - if (loaded <= *cur) { + if (loaded >= 0 && loaded <= *cur) { *cur = loaded; return 0; }