linux-user: Use __get_user() and __put_user() to handle structs in do_fcntl()
commit213d3e9ea27f7fc55db7272c05255294b52ed3e4
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 13 Jun 2016 10:22:05 +0000 (13 11:22 +0100)
committerRiku Voipio <riku.voipio@linaro.org>
Sun, 26 Jun 2016 10:16:41 +0000 (26 13:16 +0300)
treeffccf72234129c761c7c14cd252d6f82f6b58fb4
parent55d72a7eb32858d50ba0777cfde2027d007010b2
linux-user: Use __get_user() and __put_user() to handle structs in do_fcntl()

Use the __get_user() and __put_user() to handle reading and writing the
guest structures in do_ioctl(). This has two benefits:
 * avoids possible errors due to misaligned guest pointers
 * correctly sign extends signed fields (like l_start in struct flock)
   which might be different sizes between guest and host

To do this we abstract out into copy_from/to_user functions. We
also standardize on always using host flock64 and the F_GETLK64
etc flock commands, as this means we always have 64 bit offsets
whether the host is 64-bit or 32-bit and we don't need to support
conversion to both host struct flock and struct flock64.

In passing we fix errors in converting l_type from the host to
the target (where we were doing a byteswap of the host value
before trying to do the convert-bitmasks operation rather than
otherwise, and inexplicably shifting left by 1); these were
accidentally left over when the original simple "just shift by 1"
arm<->x86 conversion of commit 43f238d was changed to the more
general scheme of using target_to_host_bitmask() functions in 2ba7f73.

[RV: fixed ifdef guard for eabi functions]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user/syscall.c