]> xenbits.xensource.com Git - qemu-xen.git/commit
linux-user: Fix unaligned memory access in prlimit64 syscall
authorIlya Leoshkevich <iii@linux.ibm.com>
Fri, 24 Feb 2023 00:39:06 +0000 (01:39 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Mon, 10 Apr 2023 08:37:09 +0000 (11:37 +0300)
commitb6abbe6250a140d6f4b779f04c95e79a0f0aeffa
tree08417173559a07a96f7b0c9eb3421399912bbc4b
parentb57641e907acadd7593e0fec4ef52a21c9864aa7
linux-user: Fix unaligned memory access in prlimit64 syscall

target_rlimit64 contains uint64_t fields, so it's 8-byte aligned on
some hosts, while some guests may align their respective type on a
4-byte boundary. This may lead to an unaligned access, which is an UB.

Fix by defining the fields as abi_ullong. This makes the host alignment
match that of the guest, and lets the compiler know that it should emit
code that can deal with the guest alignment.

While at it, also use __get_user() and __put_user() instead of
tswap64().

Fixes: 163a05a8398b ("linux-user: Implement prlimit64 syscall")
Reported-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20230224003907.263914-2-iii@linux.ibm.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
(cherry picked from commit 9c1da8b5ee7f6e80e6b683e7fb73df1029a7cbbe)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
linux-user/generic/target_resource.h
linux-user/syscall.c