From patchwork Tue Mar 15 08:43:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 551430 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp3288649mag; Tue, 15 Mar 2022 02:22:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8dLS22sneY3H1wrMd1Qxc0rlqlPm+iANIEZJJjnXv83YEDvdQEayWyPCGA1nwPTvv29Gc X-Received: by 2002:a05:620a:1929:b0:67d:74f0:a957 with SMTP id bj41-20020a05620a192900b0067d74f0a957mr13466929qkb.743.1647336165853; Tue, 15 Mar 2022 02:22:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647336165; cv=none; d=google.com; s=arc-20160816; b=l0xwWVui7zHdU71REID+wKMoZKCruVFAY7Hh2bjRPOxm8vDyKPZFcDcNSZiSwTDBZe uYFAbsCwseDPzZc68nEYgB+Inu+Y65Chq6it/5tMaZvCfCThTwCz+J9pBhUKL0OhW87M DhBACp2yvsQ6ukSg2KLCU9yS3iwiS2NXDegIH8qZc0g9p8/QKdMNN/CbKb8N0DbbWZjX 1xOH3Xgk7rYzuAvJg4gaz5f40CvnNr/wkW55l6OLuTRtdo+vguwc67jXMxTdIDLFHWDs IigjVOzIZHYeTSzFzNkD3jj1hVRlF62aFKOgIhwslE5eJUNUigsPHMmEwJNxgYxuqIWX 3jZg== 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=okcfQUsJbvGgBubMBl231SWHxFIIoHPnrQLrMT7DxsE=; b=pCDP9cIg18ZHx+0qIZeHE2nszDVoBVij2eYHeip1CT2WakG1MdAbPpjn8l8N9el1qU hDf63qIz/VxoxT8WCBF6SpucoT+S1ERqiAqbLxitHJT96KuMk+JsczJVYpcF7Zp8CrPt RCtxz0KsPG+PFqeOzBFrYWoBKahp1fHCj/To9LAT88J9j4AtMJq66skdRq8p3bcT+oOU eqx4flj/Q2gNLe/yy06G0cj6eZtAiv32zi0kkhZs3+ENAc6kIAUYtdd4y63dP0hYg+bd phK9dPJSuduTI7ih3a2bUDyZ0eTydureRtSD8/OjNWQEyOoXQy7zeH07g/NgwEb8zuBD KBPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lUPJpge9; 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 q13-20020a056214194d00b00435b9b8e8f6si9656012qvk.368.2022.03.15.02.22.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Mar 2022 02:22:45 -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=lUPJpge9; 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]:46760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nU3O9-0001xD-Dw for patch@linaro.org; Tue, 15 Mar 2022 05:22:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nU2lt-0008R3-9F for qemu-devel@nongnu.org; Tue, 15 Mar 2022 04:43:13 -0400 Received: from [2607:f8b0:4864:20::436] (port=42912 helo=mail-pf1-x436.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nU2lr-00052X-M0 for qemu-devel@nongnu.org; Tue, 15 Mar 2022 04:43:12 -0400 Received: by mail-pf1-x436.google.com with SMTP id g19so18515948pfc.9 for ; Tue, 15 Mar 2022 01:43:11 -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=okcfQUsJbvGgBubMBl231SWHxFIIoHPnrQLrMT7DxsE=; b=lUPJpge9TcgreAVQ6BHdy1CA6kCDx0PFwnD+tVU7/3pNBwexqEF+4RT2kt+1zHOG4X X743szgHzLhogNqoecjuV6OOrTsNVa4wu1GVn8c0GVD9aHtJpKAJiyNfb9ZssS9lwFa4 CgfvMLkGX9dZGjEeFuKGDYKP9/4Eyh/0McO018SWXL36GQFWM+8EU9CAi3+jGgzQxhAu c1ifJI3DDD39yXLgnRT7I3dx9S/z6Spg1qANro+OJG2lggSKyKDgB9jUO1gB6JTq1cR3 yoZiZUIzTp59ZcbHWPXDL/r7xc9+nrrLXjyQtUdCVMOAXOMDCHpGyoEMkJ4PoGWQsF1D a1nA== 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=okcfQUsJbvGgBubMBl231SWHxFIIoHPnrQLrMT7DxsE=; b=Q7cHlxME7eofoUsgaWUNS/+TIIUXOwfufhiHfPrzR4ihTZcr/cvdl00/oTdcgCCEuq 87Ospv0QpXAYwgMNTbGTsRddrwV9Wcx/D97rGrJCzHIZUx2tVCjI7Szs6UHkaKze7qw6 dFhSJX/Gk1KYdKt9GiAFNQDHlHA+Q1R/JorwFKovlSrPI91OCf0dA8a5rS1UmTP7ACFH 59mS4BPLW/O61lPWNCBky4RXLIf5FeTnja/4TQyGl5bWnr45ZoSrZ0dk3G67E5LgjurU MfhIQFSGiAWX09PJSi51Djtpo3A5Vh4R6KRaNdoNSbKdzFOqpRnqxJk1h5tfbR+HVCIF nuKA== X-Gm-Message-State: AOAM530yvg59YGPIFtDPECQ/bybrzRSmvYo6yHm1mb0icK9EPL0l/6b0 wLBJgk+Cld9rlSYDeE24r+/PhFhLfvFlfA== X-Received: by 2002:a62:7981:0:b0:4f7:9e4:96e4 with SMTP id u123-20020a627981000000b004f709e496e4mr27966954pfc.4.1647333790290; Tue, 15 Mar 2022 01:43:10 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 01:43:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 1/5] linux-user/alpha: Fix sigsuspend for big-endian hosts Date: Tue, 15 Mar 2022 01:43:04 -0700 Message-Id: <20220315084308.433109-2-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::436 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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" On alpha, the sigset argument for sigsuspend is in a register. When we drop that into memory that happens in host-endianness, but target_to_host_old_sigset will treat it as target-endianness. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b9b18a7eaf..ecd00382a8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9559,7 +9559,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, { TaskState *ts = cpu->opaque; #if defined(TARGET_ALPHA) - abi_ulong mask = arg1; + /* target_to_host_old_sigset will bswap back */ + abi_ulong mask = tswapal(arg1); target_to_host_old_sigset(&ts->sigsuspend_mask, &mask); #else if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) From patchwork Tue Mar 15 08:43:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 551428 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp3271685mag; Tue, 15 Mar 2022 01:53:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykQ1eHLwNg/0whH4Q0B9uh/Iw5tMoHP/6vz3S5VP1BXIK4jQkz94NcOuXV9llV3KI5gsaJ X-Received: by 2002:a05:6214:29c6:b0:435:ad11:b3c4 with SMTP id gh6-20020a05621429c600b00435ad11b3c4mr20241951qvb.16.1647334387205; Tue, 15 Mar 2022 01:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647334387; cv=none; d=google.com; s=arc-20160816; b=qqMVis17Wivat5oo20eLdvO9ymdvj3tI0x/HA+a63gaW5/5n591PsG37yiSvhhlUfF +mwxun1eGYkEvJ9smpfmNkC+X0M4XHQ+iQc2M2uWSNBx9RuofO3pK/Sbp1+S0EQfiwWM tRrIfYMWtC2u/+UTmZQeNw0emPH1HEWSsVzlaFqzETWxHEYg2pAYffBTCeYQ1NSulyZ2 NYvZA/ANCVHxZUgh1WxV3npOYiUFKKwxxnnl50E+xGl8/eAXnCVPknShofEfSl7pwkWI iHrcXfH50Hi3q8EpaOpNfBKjSmHI8qZWUlxIcJzy7rNUND2QiBhxMyn6p1jMCZCj65Py HK/w== 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=ERpNlhEJI6fLWZOagQ9lWdhLVUwWHMh+hWen+Y5bofU=; b=HuAMuSoLf5giL+gJH2szUlZ55AXnHCitvb5tjooBJodivoEMDOKXM0X8/r9Fa/hatj mq7ThRShLDBjtKvV8sOnhwhvzTbJ0cKbbFOs49yI7ZRAYcdp8efwDXddeLvzifMhUKFj znobz2reBoV4oTm9q4MSlXAvhX/mYcCDOllQ0ANEDpAAuKZ+InUKc4GkVOjfTzZR1dEJ 3LG5kWlau5ZSHD+VgdTBhVUgng5SlL8m2wpoLuUJEYlHMVkrqmwPLVnwNtn9YpHYjRTU 9ufcOKYYsnfTgoGpAXNYtNMTDz+ZdGMIl6SSchhLRwjkyDy9x9qO8BXKK2ywr+R3XPbk 8k6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M9M42VU8; 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 h17-20020ac85e11000000b002e1a35f4e84si9126317qtx.319.2022.03.15.01.53.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Mar 2022 01:53:07 -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=M9M42VU8; 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]:53284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nU2vQ-00061k-R5 for patch@linaro.org; Tue, 15 Mar 2022 04:53:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nU2lu-0008Rd-EP for qemu-devel@nongnu.org; Tue, 15 Mar 2022 04:43:14 -0400 Received: from [2607:f8b0:4864:20::62b] (port=35807 helo=mail-pl1-x62b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nU2ls-00052d-LU for qemu-devel@nongnu.org; Tue, 15 Mar 2022 04:43:14 -0400 Received: by mail-pl1-x62b.google.com with SMTP id n15so15676396plh.2 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=ERpNlhEJI6fLWZOagQ9lWdhLVUwWHMh+hWen+Y5bofU=; b=M9M42VU87dQ337HZOgYHvEJvqT+ba1jMjlVApTWDq2/XrlyPGZhLFajsfG/bUmB8zi t2HBJljsjd6p+3FeEWONgKtvsQu1QIrRdKQirgXtOlBSaKvfmfKLzooHQEKiCJ6pbwVS Mns5caP+mUopqbwrlXyTPqGyby7BYi1IvwhZ4cYgsd8DMUG0t1S4fMB/3kHVbRfMBSkE tAPhpvJ5KOebnyvXmjDy0frCRw2/jV+HyfhRj76NqFopj1B6klsmb61H3F2M2cY6ZA3M i2Ac+ujyk1oaxsd5o13Ohs+Z1MJHOXHuOP1jgVtJp+0SmEckDBSKvGBfnlWov770NsQp Bzbg== 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=ERpNlhEJI6fLWZOagQ9lWdhLVUwWHMh+hWen+Y5bofU=; b=qRas3wKg0n3HVWr0JSPNTZnARfYB3cSjufCnbJPVuWqx0b8+9oPhECi+PfN9HOajTC PGwypg43/Pb3Qyc9Sn+rzZr0dViC9r4gC6QVxlFJUtkzU+1lUMHNT61w2ORb1/cgY1nX gmd5JhvG3Zja3tGgcePUtVmilEef54hpWzaZShxW+L8HDu2OY1c/WIx0bHpKbT27Azaa p5w4cbzYOW8YEca03NSTZYup+4JP+ics9CglSebj9aLmZaWen07md9gzMdt0c/RsURbG 1Hkg8gk30JNYOcD1FkzncQzMpYmOqVKx+Of7OYEcThvldMwTBHh0RAtPWRnrRE20d8Ko bwvQ== X-Gm-Message-State: AOAM53381EmAKWBoW2K9fSIzYoI2usSQbou8LXJ+Y1r/g2/4bWp5DKqy WnmAqRmdI6hLOxE619axhZa6jox0+Fk1pw== X-Received: by 2002:a17:902:7296:b0:14b:4bc6:e81 with SMTP id d22-20020a170902729600b0014b4bc60e81mr27028751pll.132.1647333791176; Tue, 15 Mar 2022 01:43:11 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 01:43:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/5] linux-user: Split out helpers for sigsuspend Date: Tue, 15 Mar 2022 01:43:05 -0700 Message-Id: <20220315084308.433109-3-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::62b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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" Two new functions: process_sigsuspend_mask and finish_sigsuspend_mask. Move the size check and copy-from-user code. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier --- linux-user/signal-common.h | 26 +++++++++++++++++++++++++ linux-user/signal.c | 23 ++++++++++++++++++++++ linux-user/syscall.c | 40 ++++++++++++++++---------------------- 3 files changed, 66 insertions(+), 23 deletions(-) diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index 2113165a75..6a7e4a93fc 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -92,4 +92,30 @@ abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx, */ int block_signals(void); /* Returns non zero if signal pending */ +/** + * process_sigsuspend_mask: read and apply syscall-local signal mask + * + * Read the guest signal mask from @sigset, length @sigsize. + * Convert that to a host signal mask and save it to sigpending_mask. + * + * Return value: negative target errno, or zero; + * store &sigpending_mask into *pset on success. + */ +int process_sigsuspend_mask(sigset_t **pset, target_ulong sigset, + target_ulong sigsize); + +/** + * finish_sigsuspend_mask: finish a sigsuspend-like syscall + * + * Set in_sigsuspend if we need to use the modified sigset + * during process_pending_signals. + */ +static inline void finish_sigsuspend_mask(int ret) +{ + if (ret != -QEMU_ERESTARTSYS) { + TaskState *ts = (TaskState *)thread_cpu->opaque; + ts->in_sigsuspend = 1; + } +} + #endif diff --git a/linux-user/signal.c b/linux-user/signal.c index 2a3f3cc23f..092e70b80c 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -1199,3 +1199,26 @@ void process_pending_signals(CPUArchState *cpu_env) } ts->in_sigsuspend = 0; } + +int process_sigsuspend_mask(sigset_t **pset, target_ulong sigset, + target_ulong sigsize) +{ + TaskState *ts = (TaskState *)thread_cpu->opaque; + sigset_t *host_set = &ts->sigsuspend_mask; + target_sigset_t *target_sigset; + + if (sigsize != sizeof(*target_sigset)) { + /* Like the kernel, we enforce correct size sigsets */ + return -TARGET_EINVAL; + } + + target_sigset = lock_user(VERIFY_READ, sigset, sigsize, 1); + if (!target_sigset) { + return -TARGET_EFAULT; + } + target_to_host_sigset(host_set, target_sigset); + unlock_user(target_sigset, sigset, 0); + + *pset = host_set; + return 0; +} diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ecd00382a8..154cb1c7e8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9557,41 +9557,35 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_sigsuspend case TARGET_NR_sigsuspend: { - TaskState *ts = cpu->opaque; + sigset_t *set; + #if defined(TARGET_ALPHA) + TaskState *ts = cpu->opaque; /* target_to_host_old_sigset will bswap back */ abi_ulong mask = tswapal(arg1); - target_to_host_old_sigset(&ts->sigsuspend_mask, &mask); + set = &ts->sigsuspend_mask; + target_to_host_old_sigset(set, &mask); #else - if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) - return -TARGET_EFAULT; - target_to_host_old_sigset(&ts->sigsuspend_mask, p); - unlock_user(p, arg1, 0); -#endif - ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask, - SIGSET_T_SIZE)); - if (ret != -QEMU_ERESTARTSYS) { - ts->in_sigsuspend = 1; + ret = process_sigsuspend_mask(&set, arg1, sizeof(target_sigset_t)); + if (ret != 0) { + return ret; } +#endif + ret = get_errno(safe_rt_sigsuspend(set, SIGSET_T_SIZE)); + finish_sigsuspend_mask(ret); } return ret; #endif case TARGET_NR_rt_sigsuspend: { - TaskState *ts = cpu->opaque; + sigset_t *set; - if (arg2 != sizeof(target_sigset_t)) { - return -TARGET_EINVAL; - } - if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) - return -TARGET_EFAULT; - target_to_host_sigset(&ts->sigsuspend_mask, p); - unlock_user(p, arg1, 0); - ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask, - SIGSET_T_SIZE)); - if (ret != -QEMU_ERESTARTSYS) { - ts->in_sigsuspend = 1; + ret = process_sigsuspend_mask(&set, arg1, arg2); + if (ret != 0) { + return ret; } + ret = get_errno(safe_rt_sigsuspend(set, SIGSET_T_SIZE)); + finish_sigsuspend_mask(ret); } return ret; #ifdef TARGET_NR_rt_sigtimedwait 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; From patchwork Tue Mar 15 08:43:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 551431 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp3291471mag; Tue, 15 Mar 2022 02:28:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/0Eq6w4+bF/KNkuKbUZVAMr2e93BlPWTiAtIDy8cpSTdjBQa8V2h3N50L9QjmM0DNPuCG X-Received: by 2002:a05:622a:1807:b0:2e1:c220:887b with SMTP id t7-20020a05622a180700b002e1c220887bmr14336520qtc.620.1647336486635; Tue, 15 Mar 2022 02:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647336486; cv=none; d=google.com; s=arc-20160816; b=piJuUgIFZ/i3ZtmmE6Hf+aCW5of5XL8UPZMVvDt4x53uoZV7ZAHuSWL3kUqWzHsZJu 7WMX9ggGHNnlPdQi7Q3FSq8jnPuAd3bvyXzjtMtDg5Hg6hLC3AM5dekRs3u67fOXwTF5 sIF8i69ep2PyH78mCvYI+eV10WlrM/1coUQaH3LrjPxYfrjOFSzyfxAv+dG+nVYGH21w 6ZnZ4DT25fI+5k1d/Z6IM2yEoM+/iqRarx/DuA+Oxv8/564b8A61x8J3tOL40+G7pEPw ctqJAB9W+k04LWprQYW3599EBAADNddLMfswidWU5QQ9FX7UfFx6j3FSEMm8BVvOU8dr m2nA== 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=DEJtNZJacym7P3D55T00OdkxyEJk/tkTx1LWRg3rxNs=; b=l7MaEeRn1Ge2fBwIvHfGqnZSfAaEGuQACW2KYTCg+a/JxRxoblKchaSNVgJ0ad2VBP RvNgjYuGj1c4oD12QQPFsSQFyXj2Urz2jer3SdW/p0Wuoft07vkby0tCor81WFknfFEQ f+5oJK2nRt08w1BPK6prWovhz81YbuI0cfBib2kP9pKBqeLc4Ov+b1XiW5i+/OCbkAcT +xx0EyP1AJh4Yt3PCeJKstDtUq+SfSyFzBxkQiVlrNOcu0H6FTZ1514okdeSWv+YHlSO ooPB8ostBC9ltpNwThMuJ+4xA/MpFai4bick3cGbqtTS5QpJlVFPBZ/oCgz613Xok3KA d97g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uI9ItgBW; 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 p11-20020a05620a112b00b0067b325e72d2si7071869qkk.460.2022.03.15.02.28.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Mar 2022 02:28:06 -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=uI9ItgBW; 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]:52336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nU3TK-0005k5-7s for patch@linaro.org; Tue, 15 Mar 2022 05:28:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nU2lx-0008Sw-0y for qemu-devel@nongnu.org; Tue, 15 Mar 2022 04:43:19 -0400 Received: from [2607:f8b0:4864:20::102c] (port=56227 helo=mail-pj1-x102c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nU2lu-000545-1l for qemu-devel@nongnu.org; Tue, 15 Mar 2022 04:43:15 -0400 Received: by mail-pj1-x102c.google.com with SMTP id e3so17031698pjm.5 for ; Tue, 15 Mar 2022 01:43:13 -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=DEJtNZJacym7P3D55T00OdkxyEJk/tkTx1LWRg3rxNs=; b=uI9ItgBWvpWSsUBoL2AvQnXiyn1z3DmL+NHB+QW5SVNdAoA9LyITt8p28bvbiHr0s3 QefmGlCK+HfFvxL9YAIFFnQUIlRlOVzOXuHcKM2wqEgpDKK4RO+o1JYKNbnbclQqNzju 07bu7Uh2QfBrdGAFABtP69KXD5l7Ny79J6n5YAiA+Zov9AXRpezHxIwMB4GdSYuP5I3S nMV6+jrsLHS3toxT+2UhL0PuIInco/wgaRI3BdMKFEdwUaKEjhkG3KcCnm6TD3NxhDm7 rcyLLyt0WFbbkmKZPMZEvvMcmIfln3Z2caDltnzvZxAckZ2ksExlZtYPCHZGH7Nrjcmi G5Og== 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=DEJtNZJacym7P3D55T00OdkxyEJk/tkTx1LWRg3rxNs=; b=XLgB2q4dtmxyYD7AIHpdSZIlk39ToWvm7goADls8ZEflWguj26jPh4C+LuC0h8o2og EbEDbpOXuvlXXzoMB33J3zE8lZc42Vbnu3PuxhgReZ68kLDmV5KMQT4rD+VPyORewqNL ZDLpco1NvM1loOafmUUPmdmAnKi55owBUitEX925yAkuWRVnP2h5hgCaZ659xr7Rc2YM wnKx4xLVH+zvnx6Su6O4CyUreoQaUeuPutlFOBB/vVg2dpYeAbGImf5Abky+AHsSN4+3 dbbTwHV37mAerDagaphDLHVmJ3dWfNSm4EALog6ghFziiAi9W+7PbpbMydSRXXhoHORl 3gXA== X-Gm-Message-State: AOAM531JXcetTNhXo0oslFQhtwKHclprGHsN383N1uEtoSjL3494RCQv CQUVF5Hpom38dE9yyiWSVMqxkzBrrCNYoA== X-Received: by 2002:a17:902:cec2:b0:151:b337:a699 with SMTP id d2-20020a170902cec200b00151b337a699mr27885786plg.59.1647333792820; 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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 01:43:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 4/5] linux-user: Properly handle sigset arg to epoll_pwait Date: Tue, 15 Mar 2022 01:43:07 -0700 Message-Id: <20220315084308.433109-5-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::102c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier --- 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 From patchwork Tue Mar 15 08:43:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 551432 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp2744227wrl; Tue, 15 Mar 2022 03:20:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrPNywLE+oRxjZwRNOS867soZpt+Y1wbNplIxP3o0WxVxTtlv+pM9CXLeH+vNA/XQf7ynz X-Received: by 2002:a81:1e4f:0:b0:2dc:44b3:b3ce with SMTP id e76-20020a811e4f000000b002dc44b3b3cemr23449341ywe.295.1647339653638; Tue, 15 Mar 2022 03:20:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647339653; cv=none; d=google.com; s=arc-20160816; b=Iquu39EbignLiyueO6SStp1UJ07W5GoaEyZ0KgEiTB7wrSGP5VUG1ygOrygE42eICv hvkNGSDigrAaZG6Q7x2OoebJ7S52EE9dcSbQVMuZGLh3b6B6re2k4RiWCvBV5+vy6Nfi taqx1McqS/9fT9SJ+AVUBd0fPzzCA2tY0cFGujyFy3uIw4kIXQ46um4gtq/aEYTCQmEw mxey4R8I/3Ap0cWFuvI0DpF9kDOCSjushksqpT5jNfC7OchuyZiwQQoAvtPdQHQP4vNC wF4nhjF9SN3Ac1l9A1mYzYsIKOI5G5r0e6NOXsezNkgIEbbFH5QlW1bgZWZkoTe1pyrB xhGw== 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=yQiK4Nk/B1NdX9ZTCZaM1xTMTE5yCiEd6wvHx/1Jvzs=; b=dFc6IpEFzkkm1ssW+ZoUd3gXtDhy4MQ7BR8lVpVLB2QkCnC4XOLkYQnsQnE6VOXvdc goA54bqGPfUfWNjrSSmYLkU1EwEYUpw8Rx4QT1FJNyRbB/yoe9MI9o1IQrAuvxVU9s38 1i0AWogMQ0dmUzC7P9IBKEhA/aACoQS1N5b1OnckVSdUgONhCX8WYnwwlNpzAAkM90VS fdsph/VppCEAQ+UyhuUtn9a/cR52WTqlI/r5gTywbXUwvls+M4ZA18IXRUd+NWCe/hVQ ezcAHAEvnALI20mIeqJKez+ffkjUIMEF2E/xxWmI7zYJRh39qhLYhdZ0iBL/7RWPM1m+ pZww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hwIu+VrV; 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 e135-20020a811e8d000000b002dc79742cc4si10238152ywe.542.2022.03.15.03.20.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Mar 2022 03:20:53 -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=hwIu+VrV; 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]:36956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nU4IP-0002WF-29 for patch@linaro.org; Tue, 15 Mar 2022 06:20:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nU2lx-0008Sx-0x for qemu-devel@nongnu.org; Tue, 15 Mar 2022 04:43:19 -0400 Received: from [2607:f8b0:4864:20::432] (port=41543 helo=mail-pf1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nU2lu-00054D-Q2 for qemu-devel@nongnu.org; Tue, 15 Mar 2022 04:43:15 -0400 Received: by mail-pf1-x432.google.com with SMTP id p8so18515026pfh.8 for ; Tue, 15 Mar 2022 01:43:14 -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=yQiK4Nk/B1NdX9ZTCZaM1xTMTE5yCiEd6wvHx/1Jvzs=; b=hwIu+VrVpvcUA7dlwzLcjRNIGXtyn7iW8vabWJbhCCslVc0fZFvpTdxujiZB1APy+R hRR6m9VK5QmKT2BQurCWqk8rhwxcM5fLCKgKEM/ewC/lBAiK4+SGa7/7a159XRH8e5v3 X0Bo1FvWGwHYqzhOwwV2k4mo1k+oSVGeI9PqHea2IKe468AeYpzBlyt1RVOXSfUQr1HC 6ptD9BEuoA1AHjx5p9S1KND7FRUWRn7w2doy64d/ld/YaFrRoy0wRbClkgT7lfsXx2vU hfqIzOlLprTTcxuz7AZrvZQJ0o0UTtRPCUr/tEiGRw56e9foMCDVSW3UVyTxNJ5kUQBL AvLg== 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=yQiK4Nk/B1NdX9ZTCZaM1xTMTE5yCiEd6wvHx/1Jvzs=; b=uzDsJKKnVy7kba7DbZ1wKAIHsK/FDuVNpthCbWw3JxI2uR/NefUC9o9LO76Lfjqv6I lRXUGqW9KcVLHXb6ZZXsMpGoYHAaEYhnK8az7v1zfjkJuvD5uann6+XjdaddHOYPQy9e sA48UtSbzwhSU7uLDE16193/2/fz3e4nVav/cjCieOdCxl2NqX+5RLmK3cIlrkkFaJD6 ygLxTbu/m6n6oP2wygQslMLVXmxX8jSr3r4jrXQvfMxbdGYDp1un4cXZTU41loxDP+HT J+xSrX/t1WQMRlkGmZt129bZKzNLuTZPywtC0yAVKaEiGqxy5nP1WEc6yHAJzrlrQuV/ 9O5w== X-Gm-Message-State: AOAM5323hVOKbO6KO8PdBsGac8/N8eEZzU6tRWwZvmH5FcwwUQeAcxQE XXMJvWWViLCoT1a/mIUfWfAF4gf/ufSuBg== X-Received: by 2002:a63:864a:0:b0:375:7999:e83c with SMTP id x71-20020a63864a000000b003757999e83cmr23457367pgd.144.1647333793552; Tue, 15 Mar 2022 01:43:13 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 01:43:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 5/5] linux-user: Properly handle sigset arg to ppoll Date: Tue, 15 Mar 2022 01:43:08 -0700 Message-Id: <20220315084308.433109-6-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::432 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.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. Signed-off-by: Richard Henderson Reviewed-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 85de4e1bc7..a69b7084f1 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)) { + ret = process_sigsuspend_mask(&set, arg4, arg5); + if (ret != 0) { unlock_user(target_pfd, arg1, 0); - return -TARGET_EINVAL; + return ret; } - - target_set = lock_user(VERIFY_READ, arg4, - sizeof(target_sigset_t), 1); - if (!target_set) { - unlock_user(target_pfd, arg1, 0); - return -TARGET_EFAULT; - } - 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;