diff options
author | Ilya Leoshkevich <iii@linux.ibm.com> | 2023-02-24 01:39:06 +0100 |
---|---|---|
committer | Laurent Vivier <laurent@vivier.eu> | 2023-03-10 20:42:00 +0100 |
commit | 9c1da8b5ee7f6e80e6b683e7fb73df1029a7cbbe (patch) | |
tree | cc36882bc54296678a450d7628b5f80164658031 /linux-user/generic | |
parent | fa2229dbf8e529f767d86db9e39b7e829c6759ed (diff) | |
download | qemu-9c1da8b5ee7f6e80e6b683e7fb73df1029a7cbbe.zip qemu-9c1da8b5ee7f6e80e6b683e7fb73df1029a7cbbe.tar.gz qemu-9c1da8b5ee7f6e80e6b683e7fb73df1029a7cbbe.tar.bz2 |
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>
Diffstat (limited to 'linux-user/generic')
-rw-r--r-- | linux-user/generic/target_resource.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/linux-user/generic/target_resource.h b/linux-user/generic/target_resource.h index 539d8c4..37d3eb0 100644 --- a/linux-user/generic/target_resource.h +++ b/linux-user/generic/target_resource.h @@ -12,8 +12,8 @@ struct target_rlimit { }; struct target_rlimit64 { - uint64_t rlim_cur; - uint64_t rlim_max; + abi_ullong rlim_cur; + abi_ullong rlim_max; }; #define TARGET_RLIM_INFINITY ((abi_ulong)-1) |