[PATCH 4/5] linux-user: Properly handle sigset arg to epoll_pwait

Richard Henderson posted 5 patches 3 years, 9 months ago
Maintainers: Laurent Vivier <laurent@vivier.eu>
[PATCH 4/5] linux-user: Properly handle sigset arg to epoll_pwait
Posted by Richard Henderson 3 years, 9 months ago
Unblocked signals are never delivered, because we
didn't record the new mask for process_pending_signals.
Handle this with the same mechanism as sigsuspend.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8071a5191d..85de4e1bc7 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -12694,29 +12694,21 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_epoll_pwait)
         case TARGET_NR_epoll_pwait:
         {
-            target_sigset_t *target_set;
-            sigset_t _set, *set = &_set;
+            sigset_t *set = NULL;
 
             if (arg5) {
-                if (arg6 != sizeof(target_sigset_t)) {
-                    ret = -TARGET_EINVAL;
+                ret = process_sigsuspend_mask(&set, arg5, arg6);
+                if (ret != 0) {
                     break;
                 }
-
-                target_set = lock_user(VERIFY_READ, arg5,
-                                       sizeof(target_sigset_t), 1);
-                if (!target_set) {
-                    ret = -TARGET_EFAULT;
-                    break;
-                }
-                target_to_host_sigset(set, target_set);
-                unlock_user(target_set, arg5, 0);
-            } else {
-                set = NULL;
             }
 
             ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, timeout,
                                              set, SIGSET_T_SIZE));
+
+            if (set) {
+                finish_sigsuspend_mask(ret);
+            }
             break;
         }
 #endif
-- 
2.25.1
Re: [PATCH 4/5] linux-user: Properly handle sigset arg to epoll_pwait
Posted by Laurent Vivier 3 years, 8 months ago
Le 15/03/2022 à 09:43, Richard Henderson a écrit :
> Unblocked signals are never delivered, because we
> didn't record the new mask for process_pending_signals.
> Handle this with the same mechanism as sigsuspend.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   linux-user/syscall.c | 22 +++++++---------------
>   1 file changed, 7 insertions(+), 15 deletions(-)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>