61 lines
2.4 KiB
Diff
61 lines
2.4 KiB
Diff
|
|
From 828944a7eb5d67f81aa3bc7158860466dc1f1325 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Richard Henderson <richard.henderson@linaro.org>
|
||
|
|
Date: Fri, 5 Apr 2024 11:58:14 -1000
|
||
|
|
Subject: [PATCH] linux-user: Fix waitid return of siginfo_t and rusage
|
||
|
|
MIME-Version: 1.0
|
||
|
|
Content-Type: text/plain; charset=UTF-8
|
||
|
|
Content-Transfer-Encoding: 8bit
|
||
|
|
|
||
|
|
The copy back to siginfo_t should be conditional only on arg3,
|
||
|
|
not the specific values that might have been written.
|
||
|
|
The copy back to rusage was missing entirely.
|
||
|
|
|
||
|
|
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2262
|
||
|
|
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
|
||
|
|
Tested-by: Alex Fan <alex.fan.q@gmail.com>
|
||
|
|
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||
|
|
(cherry picked from commit f0907ff4cae743f1a4ef3d0a55a047029eed06ff)
|
||
|
|
Signed-off-by: zhujun2 <zhujun2_yewu@cmss.chinamobile.com>
|
||
|
|
---
|
||
|
|
linux-user/syscall.c | 22 ++++++++++++++++------
|
||
|
|
1 file changed, 16 insertions(+), 6 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
|
||
|
|
index a5fe399277..c4951d449f 100644
|
||
|
|
--- a/linux-user/syscall.c
|
||
|
|
+++ b/linux-user/syscall.c
|
||
|
|
@@ -8460,14 +8460,24 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||
|
|
#ifdef TARGET_NR_waitid
|
||
|
|
case TARGET_NR_waitid:
|
||
|
|
{
|
||
|
|
+ struct rusage ru;
|
||
|
|
siginfo_t info;
|
||
|
|
- info.si_pid = 0;
|
||
|
|
- ret = get_errno(safe_waitid(arg1, arg2, &info, arg4, NULL));
|
||
|
|
- if (!is_error(ret) && arg3 && info.si_pid != 0) {
|
||
|
|
- if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0)))
|
||
|
|
+
|
||
|
|
+ ret = get_errno(safe_waitid(arg1, arg2, (arg3 ? &info : NULL),
|
||
|
|
+ arg4, (arg5 ? &ru : NULL)));
|
||
|
|
+ if (!is_error(ret)) {
|
||
|
|
+ if (arg3) {
|
||
|
|
+ p = lock_user(VERIFY_WRITE, arg3,
|
||
|
|
+ sizeof(target_siginfo_t), 0);
|
||
|
|
+ if (!p) {
|
||
|
|
+ return -TARGET_EFAULT;
|
||
|
|
+ }
|
||
|
|
+ host_to_target_siginfo(p, &info);
|
||
|
|
+ unlock_user(p, arg3, sizeof(target_siginfo_t));
|
||
|
|
+ }
|
||
|
|
+ if (arg5 && host_to_target_rusage(arg5, &ru)) {
|
||
|
|
return -TARGET_EFAULT;
|
||
|
|
- host_to_target_siginfo(p, &info);
|
||
|
|
- unlock_user(p, arg3, sizeof(target_siginfo_t));
|
||
|
|
+ }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return ret;
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|