From patchwork Tue Mar 15 08:43:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 551427 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp3267784mag; Tue, 15 Mar 2022 01:45:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTwm8URngqc8RnAEZCMb1B7KJCQeOz3N5GhJsCtqiMCZxmI+IbtTK3depvxzl+b6WT97yw X-Received: by 2002:a05:622a:1309:b0:2e1:cc2f:3738 with SMTP id v9-20020a05622a130900b002e1cc2f3738mr10364276qtk.655.1647333955989; Tue, 15 Mar 2022 01:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647333955; cv=none; d=google.com; s=arc-20160816; b=J9uzclFxhnXFG11YyqrYPn5NNCLL8ttncuhTi0LWsINxaGnZAUB9vckKegd5XenO26 PsEXsNM7vjMoeZPUSltKdBQvtSJnRJ4o52ai12xej4+J+u1ZhD7CKFnQDASE3S9T6ULC cXp415SiHtK94s/DWDx56rchArfp0ZCSQcokBD9wWHCdoRcdSbBdUTgvsgqlgz+ISTL5 iyt2teuXq9YH4y2EqMC29wF+SbPT9sKGHa20D5KfB6R/bNGhcBCAhmZ+tduE7XIvWAm8 YietWc7jjoyjzmqBp6S7qMBf7qBz/h/Xc9/wKX1wTPQEJ5a1Y+b3EqpN1v74q6UaFsRx 0Ycw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=h3suoOPDLcx3C2TGXcLsoIqq/PtT5yRHwOoMlS2gYo4=; b=G01nj2Grfzx7AxWHgASZsXedWNSAT2cvwZmMsO6eBaUjMS8iXMaeDluc05O5p9No8q daNmAG+JattJfgjtHcqUcS+9wU459G5P9Bn+9RUKo2GtP9lYiPpC6j37dpuWtQyp6Rnc u5oaCOmgbWv48sPWan4A1gZIjPrsmn2xKey1ZFlfWBbvwNsCib/bmgUKiWp3rvRLaths zN//e6iXTNrbrTlUtq0IGid0WoGu7rg0ahMaR8NOGRHRVuTpk9PX5xR23gByKeWDMnDd aihqT3U9QNEzhfHpQdOeb6CwB1/ILTjiQp1dz1U8eBwc6HvCKtEJMlwUNTHuYamg2x5h mVZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gGOb7A/y"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x17-20020a05620a259100b0067b31fe94d6si8340129qko.612.2022.03.15.01.45.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Mar 2022 01:45:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gGOb7A/y"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nU2oV-0008W9-FD for patch@linaro.org; Tue, 15 Mar 2022 04:45:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nU2lu-0008Rq-Rn for qemu-devel@nongnu.org; Tue, 15 Mar 2022 04:43:14 -0400 Received: from [2607:f8b0:4864:20::62f] (port=36851 helo=mail-pl1-x62f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nU2lt-00052l-9V for qemu-devel@nongnu.org; Tue, 15 Mar 2022 04:43:14 -0400 Received: by mail-pl1-x62f.google.com with SMTP id e13so15671822plh.3 for ; Tue, 15 Mar 2022 01:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h3suoOPDLcx3C2TGXcLsoIqq/PtT5yRHwOoMlS2gYo4=; b=gGOb7A/yBU1OlwmBSHbvFXOR2MtGC+eqBwbtIwffXWOMT7xi/dGHzi7fS+xDAm5z3v iCEg97OWGZO6v5IZ7hQIhxRP2SPUczo6uOv4RmNq0SZfgcBUmeFi24PYCPnGp9BE3mfT kCQD5w0Wtxss6uuYs42HIzuhflqJ7YTEAPwp+jCfrtnQ6/AFgfKyhEiEjt3ZSL7Hqgzf WZu/TqfcXr2FH3cy0YTHRq/lor8dMc97YQgawwpgA7L8HVcOiYEsfLOStBHkx0dZZKeB s0HtdTpyOTYKGq3MTI3NNbo+RMEwxyT/+KTM+hE0GbdoadiozXqppDeTXzGS4hQe6khI l04g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h3suoOPDLcx3C2TGXcLsoIqq/PtT5yRHwOoMlS2gYo4=; b=mS4zgHZccF9SUmgS2GbAIogyu2BPVD2+Geq+1iJWv0IytAbXqzdQGOBlQ9Ew5oClDi qVxrYE1WJMTn7RhWuH8KbCmpNfMCnncV89NDEX8rg/Vy1Lehc82C4S2iFObBe10CctHJ HmnHngSjPoAZDsCYhCOCv2xc50ELeMuDQgb67v+aNxGUBj32kuIknGEeQKFZJT1tEgXs xcDnhnOcrdoc/8vNKjvCiRoFCRTTdTH98vR5AOg6iMtHG5rqOHSshKPrH1BQA9Oes5/+ m2yOLVyTOvzUfMZT2BNmxP/+ok8po6EJRthTV56fpAovyRhopOBfbshtpu9hAfRdqWF+ 1O3A== X-Gm-Message-State: AOAM532VV+G2pCxZkYdNskVMTU8zYef/p1Fvt1SGC6bZ2EyT+lPSk0rf BjwuKXMUObyvCOfzyFxmpP/KMmXKVW3H7A== X-Received: by 2002:a17:902:d4cc:b0:153:32a9:2479 with SMTP id o12-20020a170902d4cc00b0015332a92479mr20602063plg.25.1647333792006; Tue, 15 Mar 2022 01:43:12 -0700 (PDT) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id ob13-20020a17090b390d00b001becfd7c6f3sm2233762pjb.27.2022.03.15.01.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 01:43:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 3/5] linux-user: Properly handle sigset arg to pselect Date: Tue, 15 Mar 2022 01:43:06 -0700 Message-Id: <20220315084308.433109-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220315084308.433109-1-richard.henderson@linaro.org> References: <20220315084308.433109-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/834 Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 154cb1c7e8..8071a5191d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1391,14 +1391,12 @@ static abi_long do_pselect6(abi_long arg1, abi_long arg2, abi_long arg3, * The 6th arg is actually two args smashed together, * so we cannot use the C library. */ - sigset_t set; struct { sigset_t *set; size_t size; } sig, *sig_ptr; abi_ulong arg_sigset, arg_sigsize, *arg7; - target_sigset_t *target_sigset; n = arg1; rfd_addr = arg2; @@ -1439,10 +1437,8 @@ static abi_long do_pselect6(abi_long arg1, abi_long arg2, abi_long arg3, } /* Extract the two packed args for the sigset */ + sig_ptr = NULL; if (arg6) { - sig_ptr = &sig; - sig.size = SIGSET_T_SIZE; - arg7 = lock_user(VERIFY_READ, arg6, sizeof(*arg7) * 2, 1); if (!arg7) { return -TARGET_EFAULT; @@ -1452,28 +1448,22 @@ static abi_long do_pselect6(abi_long arg1, abi_long arg2, abi_long arg3, unlock_user(arg7, arg6, 0); if (arg_sigset) { - sig.set = &set; - if (arg_sigsize != sizeof(*target_sigset)) { - /* Like the kernel, we enforce correct size sigsets */ - return -TARGET_EINVAL; + ret = process_sigsuspend_mask(&sig.set, arg_sigset, arg_sigsize); + if (ret != 0) { + return ret; } - target_sigset = lock_user(VERIFY_READ, arg_sigset, - sizeof(*target_sigset), 1); - if (!target_sigset) { - return -TARGET_EFAULT; - } - target_to_host_sigset(&set, target_sigset); - unlock_user(target_sigset, arg_sigset, 0); - } else { - sig.set = NULL; + sig_ptr = &sig; + sig.size = SIGSET_T_SIZE; } - } else { - sig_ptr = NULL; } ret = get_errno(safe_pselect6(n, rfds_ptr, wfds_ptr, efds_ptr, ts_ptr, sig_ptr)); + if (sig_ptr) { + finish_sigsuspend_mask(ret); + } + if (!is_error(ret)) { if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n)) { return -TARGET_EFAULT;