[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 4/8] linux-user: fix mq_getsetattr implementation
From: |
Max Filippov |
Subject: |
[Qemu-devel] [PULL 4/8] linux-user: fix mq_getsetattr implementation |
Date: |
Mon, 2 Apr 2018 10:13:50 -0700 |
mq_getsetattr implementation does not set errno correctly in case of
error. Also in the presence of both 2nd and 3rd arguments it calls both
mq_getattr and mq_setattr, whereas only the latter call would suffice.
Don't call mq_getattr in the presence of the 2nd argument. Don't copy
output back to user in case of error. Use get_errno to set errno value.
This fixes test rt/tst-mqueue2 from the glibc testsuite.
Cc: Lionel Landwerlin <address@hidden>
Cc: Kirill A. Shutemov <address@hidden>
Cc: Riku Voipio <address@hidden>
Cc: Aurelien Jarno <address@hidden>
Cc: Laurent Vivier <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
Signed-off-by: Max Filippov <address@hidden>
---
linux-user/syscall.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 18ea79140f16..d51e2a00ee31 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -12092,15 +12092,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
{
struct mq_attr posix_mq_attr_in, posix_mq_attr_out;
ret = 0;
- if (arg3 != 0) {
- ret = mq_getattr(arg1, &posix_mq_attr_out);
- copy_to_user_mq_attr(arg3, &posix_mq_attr_out);
- }
if (arg2 != 0) {
copy_from_user_mq_attr(&posix_mq_attr_in, arg2);
- ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out);
+ ret = get_errno(mq_setattr(arg1, &posix_mq_attr_in,
+ &posix_mq_attr_out));
+ } else if (arg3 != 0) {
+ ret = get_errno(mq_getattr(arg1, &posix_mq_attr_out));
+ }
+ if (ret == 0 && arg3 != 0) {
+ copy_to_user_mq_attr(arg3, &posix_mq_attr_out);
}
-
}
break;
#endif
--
2.11.0
- [Qemu-devel] [PULL 0/8] xtensa-specific and generic fixes for linux-user, Max Filippov, 2018/04/02
- [Qemu-devel] [PULL 1/8] target/xtensa: fix flush_window_regs, Max Filippov, 2018/04/02
- [Qemu-devel] [PULL 2/8] target/xtensa: linux-user: rewind pc for restarted syscall, Max Filippov, 2018/04/02
- [Qemu-devel] [PULL 3/8] linux-user: call cpu_copy under clone_lock, Max Filippov, 2018/04/02
- [Qemu-devel] [PULL 4/8] linux-user: fix mq_getsetattr implementation,
Max Filippov <=
- [Qemu-devel] [PULL 5/8] target/xtensa: linux-user: fix sysv IPC structures, Max Filippov, 2018/04/02
- [Qemu-devel] [PULL 6/8] linux-user: fix error propagation in clock_gettime, Max Filippov, 2018/04/02
- [Qemu-devel] [PULL 7/8] linux-user: implement clock_settime, Max Filippov, 2018/04/02
- [Qemu-devel] [PULL 8/8] target/xtensa: linux-user: fix fadvise64 call, Max Filippov, 2018/04/02
- Re: [Qemu-devel] [PULL 0/8] xtensa-specific and generic fixes for linux-user, Peter Maydell, 2018/04/03