From patchwork Thu Mar 24 08:20:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 553902 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp4189802mag; Thu, 24 Mar 2022 01:31:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJYvGppJT5rR2Y4oxGLrukwwV9RBCaGHnURln25QvXcXg7OKNWhS7EI4qKC+X8zG4jIZqR X-Received: by 2002:ac8:5a47:0:b0:2e1:e78c:8367 with SMTP id o7-20020ac85a47000000b002e1e78c8367mr3471339qta.126.1648110714363; Thu, 24 Mar 2022 01:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648110714; cv=none; d=google.com; s=arc-20160816; b=k40LF5KliBn3mnOrkmTbCykwZG4ARbJYQkWzdOC+MOXTCfY9+nQur0NAWa0LaaacoD icOxrx2ovP8a3X+Du6Jia3Arp6Rw63qAa5PB16azGAw80I6uLVCdVcVPau8IAy5VuvCh m/LaYgG7HHjOMO8e2kLFzXrV0PiWcAimc3IXltFNKSO1fFgI36ISh0pBcJ80a8mro4po ankPxP9pdr/J13Pikcvo0QzB4wPG9T8OzEpHdKqarT7uep0J+RzBw+f9Iau9DL6rQRfJ aX9QFj+BGAbJUwtZxZF7fvf6bs0D2TFb+p/3tSGLy63EkAKC/jXKsp5eclo9cvC/dkRj SjRQ== 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; bh=5hnvLsiljUmEh3ipLvN3djysVLtYndXhLCEV/PT4I7M=; b=lHRdg2h+/vsgJnt/iuxJKqQghDpHr4VIcAbBxcBrhCMX7HpMCynCxoDG+HjpQsmeHO z+MZoBnyS1NjDSMR/iDxB9Djh/en8khQB7t0wXymjm7IcSjMlBgL22peijdJhtrJeV8l Eb/s6EIXfh0hRUls7yNQN62W3Jv1MmlRdB74NBGE1KO4l4VjAkmQbF3/TrZ2uQBUXJx9 DvCM5ViAp0W8fOzkU24NNQ9AlGkhUWZDpp/lJak8I4IM45WSpIFSWFtEEQ4QKJ+FhqSm GiAsvry4fxzbEdtG7zQdvvpwr/y2UinhjoT96vCWYyXlZRTxUuNHPT7MYKJwXdYSBk/X TSrw== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v129-20020a379387000000b0067e4be237e4si4871826qkd.41.2022.03.24.01.31.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Mar 2022 01:31:54 -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; 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" Received: from localhost ([::1]:45590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXIsr-0000ms-Pc for patch@linaro.org; Thu, 24 Mar 2022 04:31:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXIhm-0005wp-Us for qemu-devel@nongnu.org; Thu, 24 Mar 2022 04:20:27 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:52963) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXIhk-0003P6-Nl for qemu-devel@nongnu.org; Thu, 24 Mar 2022 04:20:26 -0400 Received: from quad ([82.142.12.150]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MYedH-1ncZtN2BQB-00VkSn; Thu, 24 Mar 2022 09:20:22 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 06/10] linux-user: Properly handle sigset arg to ppoll Date: Thu, 24 Mar 2022 09:20:12 +0100 Message-Id: <20220324082016.3463521-7-laurent@vivier.eu> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220324082016.3463521-1-laurent@vivier.eu> References: <20220324082016.3463521-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:MQj22sMYeCS9DSnLGnftAziUQubUY1cVCcQYrGZ/TXFuChSRtpp MBqTNR7JVpT/DmGopMRWVlAOtLxQKeUwBUlIplTmo7cxhH9hL2aeTrXDkPngF/vQoZDQPz7 dFtA7j9AOQ9Mj+2CJDiJKg8V2WQSVCjcZnKnij0UoimmIlvpOa5n4qSARTYdzFGBiKrmMEn PXWGmiQYq+Y/QRZ4WQNVw== X-UI-Out-Filterresults: notjunk:1;V03:K0:Ok2kemLSHks=:xJFPqQEB73fSWlGhuF1DmZ oRp29qwRfb2PFvt+8d4NsZzw1+4MdBHV5rb3Kp1/Y53L/a+DNdKpjTHSSUHqrbnX2DnupuNY8 sgJ/8XzRSzU6ZaN9tPj7eO33sy1+94zM5Jf0D4tpmKwc3UirQNmaNp/AjIQdgJ6+OnjAIJyCr lPANd25mJL1cGIpiCuCPWru1ogcM3QiQYvNp8OPrCyB/tjKrvSh6edq1jzXYKCiKabTP0dYvJ Y4H/N/d92w9chuMfWH+090RZ7ICIWVSiwk4thYT7ClpvXYTKcAqUkbOMMASnbcA7KYkgTIq4X 9P1boUDdfMdpQKqFT31UfjHujHTYqflAHOODWoaV3Q2N3xhm7y6IhmE9MTfpclw8JZWEjNMsg nxdvhY7mlDkRHIS8Hu9m9yRMvoeKgpz3j9FLJRHYbbxKLVMJhdGjqr2FWfv0cpKtOEDwMeWZC XBIoMAVu15xohtAga5hwPGbFAjXC6fRXdEpNsTEPNMrj01qv70X9atPiHiV/zxaCv3wezVsUE +aidZ9gwdQ8xCX1deD/5gA9ZUi2Ts04lsjCys3HZYZlFm8a3Czxh7XgAYcDJbEpcCFeHljWoX VLpzeVxUJ+tdIyGVLPyCiAzbpntVxIOxNJIfpgtWB0JpSajz0PKqCdSaTKK3oVvaF4wxStam+ XCSHCQQR2ujYy6blO5kAo22SJixXhNUBkr+fwqlJ+D4u6Bz57tlConu50sUOYsUdGjWk= Received-SPF: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson 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 Reviewed-by: Laurent Vivier Message-Id: <20220315084308.433109-6-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 67af40deac07..f65045efe6a2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1519,8 +1519,7 @@ static abi_long do_ppoll(abi_long arg1, abi_long arg2, abi_long arg3, } if (ppoll) { struct timespec _timeout_ts, *timeout_ts = &_timeout_ts; - target_sigset_t *target_set; - sigset_t _set, *set = &_set; + sigset_t *set = NULL; if (arg3) { if (time64) { @@ -1539,25 +1538,19 @@ static abi_long do_ppoll(abi_long arg1, abi_long arg2, abi_long arg3, } if (arg4) { - if (arg5 != sizeof(target_sigset_t)) { - unlock_user(target_pfd, arg1, 0); - return -TARGET_EINVAL; - } - - target_set = lock_user(VERIFY_READ, arg4, - sizeof(target_sigset_t), 1); - if (!target_set) { + ret = process_sigsuspend_mask(&set, arg4, arg5); + if (ret != 0) { unlock_user(target_pfd, arg1, 0); - return -TARGET_EFAULT; + return ret; } - target_to_host_sigset(set, target_set); - } else { - set = NULL; } ret = get_errno(safe_ppoll(pfd, nfds, timeout_ts, set, SIGSET_T_SIZE)); + if (set) { + finish_sigsuspend_mask(ret); + } if (!is_error(ret) && arg3) { if (time64) { if (host_to_target_timespec64(arg3, timeout_ts)) { @@ -1569,9 +1562,6 @@ static abi_long do_ppoll(abi_long arg1, abi_long arg2, abi_long arg3, } } } - if (arg4) { - unlock_user(target_set, arg4, 0); - } } else { struct timespec ts, *pts;