xemu/linux-user/generic
Ilya Leoshkevich b6abbe6250 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: 163a05a839 ("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>
2023-04-10 11:37:09 +03:00
..
fcntl.h linux-user: Remove obsolete F_SHLCK and F_EXLCK translation 2021-01-21 13:27:34 +01:00
signal.h linux-user: Remove TARGET_SIGSTKSZ 2022-01-06 11:40:52 +01:00
sockbits.h linux-user: add TARGET_SO_{DOMAIN,PROTOCOL} 2021-02-13 22:50:50 +01:00
target_errno_defs.h linux-user: Create special-errno.h 2021-12-19 20:47:33 -08:00
target_mman.h linux-user: Provide MADV_* definitions 2022-09-27 09:30:09 +02:00
target_prctl_unalign.h linux-user: Add code for PR_GET/SET_UNALIGN 2022-01-06 11:40:52 +01:00
target_resource.h linux-user: Fix unaligned memory access in prlimit64 syscall 2023-04-10 11:37:09 +03:00
target_structs.h linux-user: Move target_struct.h generic definitions to generic/ 2022-01-11 18:40:44 +01:00
termbits.h linux-user: Add generic 'termbits.h' for some archs 2020-08-27 12:29:50 +02:00