]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commit
linux-user: Don't overrun guest buffer in sched_getaffinity
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 15 May 2014 13:40:23 +0000 (14:40 +0100)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 3 Jul 2014 21:31:30 +0000 (16:31 -0500)
commitccb08f53d5cb084b2ea5449f0176b9bbe20571ed
treed03b4604cde4b4e6ca1435dee9379ed44954ac62
parentcb34d1e9e938f42aacbd85c8d0ac08b66d44ad29
linux-user: Don't overrun guest buffer in sched_getaffinity

If the guest's "long" type is smaller than the host's, then
our sched_getaffinity wrapper needs to round the buffer size
up to a multiple of the host sizeof(long). This means that when
we copy the data back from the host buffer to the guest's
buffer there might be more than we can fit. Rather than
overflowing the guest's buffer, handle this case by returning
EINVAL or ignoring the unused extra space, as appropriate.

Note that only guests using the syscall interface directly might
run into this bug -- the glibc wrappers around it will always
use a buffer whose size is a multiple of 8 regardless of guest
architecture.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
(cherry picked from commit be3bd286bc06bb68cdc71748d9dd4edcd57b2b24)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
linux-user/syscall.c