From patchwork Fri Nov 15 20:58:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 843519 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcc:0:b0:382:184f:390f with SMTP id e12csp1058402wrc; Fri, 15 Nov 2024 13:02:08 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW4L5ptSGTzdWJIogoJfmFhO5D5aT1oaZ1nt53jqq5UN110/ZvPNoD7ggG6gR6ALA5DsyLEdg==@linaro.org X-Google-Smtp-Source: AGHT+IEdTP6VhVXvgPEPSU9FMrJya4K1cKZhMBYCncS5wB5ajyi0Cza7Bj8TQ5T6awxmO2jq4C2O X-Received: by 2002:a54:4002:0:b0:3e7:be26:e2e4 with SMTP id 5614622812f47-3e7be26e3damr2987531b6e.0.1731704527784; Fri, 15 Nov 2024 13:02:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731704527; cv=none; d=google.com; s=arc-20240605; b=Q87OD9PDA8aSxYLZm4wY05kX4QKBiMFAfBS37TIJvwiWc6ngALpSa/T40WtYG7G9vN k65fN6Zyq+PjGykskzgOY2N2x45NcBz5Qnadx1fwRY8oMlsIvwDPDOOYj+otaZ4tR/Ny N8qbjDvrvyPOYFHXGqhskcBYPHrE5qYxzZBI4yp9geQoPFOIJb5MDZm5SpN/trcC8X5G 331MmmRHDYK+obSOmixYeAHxYEH5B0PN0Ja+h+Sr3QtohMKHB/WE7+sMZNpuNwUfUHSq ePjaNQMV9ePtEDowoa2e9KF9PotP5Lk+oOiwsn3fmkTjZ2B3oVimCryeF0jL723H/qj3 HzZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=mQ2OtP14Y6YgrVCa1qLJ59lo8Li0ZXwEANDkZj5mi5k=; fh=o2XzhdKG+B45MJCghEfnYoypmHvLX2hd4SL6yXeiyXI=; b=hzgKoG67VOizU7L2ob8Q4ItHoxUJSiPXE8P1pY89EvDP7r2zef/NV759jPkJXMo+zZ 3i/5gm10YQeX6os2JVx/0BslomzO1FuCmdMrGgEUb2Iof5cw2++HhkKKA7Fe9oDPKkjh vaBITCvq7XCec+QKzNlwrJLCZwnC8VIUvydL6E9iYMQPvU3V5iLgLgqLsGED7MlrjnYl 5V8Y6jKBmby75I6gl2B3GL3YQtqZ4fo1zcKZMKznHOY4zJm/s/t4kOHyvJuDaqmCgiy5 wbdPjOA1u9CWwZjOAse4XIqhBvc4AVsuSXdUobjczgPHmqg2zRyFzUKe2W7Zs1CC+Mpv DeJQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="a/dFTf/h"; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a1e0cc1a2514c-856f79780a1si16511241.101.2024.11.15.13.02.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Nov 2024 13:02:07 -0800 (PST) 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="a/dFTf/h"; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tC3PC-0007Wc-8c; Fri, 15 Nov 2024 15:59:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tC3P8-0007Vf-W5 for qemu-devel@nongnu.org; Fri, 15 Nov 2024 15:58:59 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tC3P7-0004NG-7h for qemu-devel@nongnu.org; Fri, 15 Nov 2024 15:58:58 -0500 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2ea08667b23so1813523a91.2 for ; Fri, 15 Nov 2024 12:58:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731704336; x=1732309136; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mQ2OtP14Y6YgrVCa1qLJ59lo8Li0ZXwEANDkZj5mi5k=; b=a/dFTf/hFe+csNMZdAvRLxuZY4xiI6QByn/LZEfp8Q4pp35EdeBV+K83Y5+INiW9d0 hvERvJBvzD3PHz+MGkimOPS6qiWkjBU6Hb4PhPoNd7XP+psC/sqJHKyko3CQebOHi2QA MYcDOgpKBgK6egxt/2u285LUE6PA7YRmsGFdzHpH7yjZK0AmeEOGX3S4Sosxh+8anaFB 90qDLFVRCWyyoBPTEx1js+NSJO4ZgPct5/e7Yf1lAFyV6+gmyInTX1NLKH0rkwcUp4qm pn+HMvV9TXpC8zYn4c303NWvlEVoRY8INK7ub5jHex141w/QL1ZmbjX7wsV2GLXk+UcC Gr7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731704336; x=1732309136; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mQ2OtP14Y6YgrVCa1qLJ59lo8Li0ZXwEANDkZj5mi5k=; b=DjkkD8YDSGqavlhGqRd/ube7SUtl+vKb80PCQ/OfPNe3Qtdq8cnD1puKqpOKBUqvpl lGbFL6Cg5FIt3yPNoTtiyah/TO3dEM8itOFyz6+uYuqpzb+nDbF/30OIDklM4iLz8qiZ 4yCunSVrB3rIlsATiMJcDYTguHgPJwF0i/ch9r194hYQAI+tamo2G2DU3BEGgLWHuRmE mqLXR9JslgHr6mPCttx0+8lNPSkEh08M1Eqxt5n6/4kQH8pG6sqsjDr4Jsfdpv3P2nf+ nZLefzY+kRk73tZLQFf7kmLly5M3TNnvA56jJ3DEiWy7bBvSGUkEls9Rk0l+0s9iLVYD N9aA== X-Gm-Message-State: AOJu0YwEM0MEKelv6AyeqHw2VVD2OXfGODaCHt9GhlyGCHpAAQOTN6oi 5Icoi5ZN2OQZaeNVYDCoM+0uNJBLlncQXWHffr0KnClyjIrJhenAVRt7peesAdrSz2bhKOr3zG8 w X-Received: by 2002:a17:90b:4c84:b0:2e2:a097:bb02 with SMTP id 98e67ed59e1d1-2ea154f5eabmr4577431a91.11.1731704335638; Fri, 15 Nov 2024 12:58:55 -0800 (PST) Received: from stoup.. ([71.212.136.242]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ea024a49a8sm3362274a91.23.2024.11.15.12.58.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 12:58:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich Subject: [PULL 04/14] tests/tcg: Test that sigreturn() does not corrupt the signal mask Date: Fri, 15 Nov 2024 12:58:39 -0800 Message-ID: <20241115205849.266094-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241115205849.266094-1-richard.henderson@linaro.org> References: <20241115205849.266094-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Ilya Leoshkevich Add a small test to prevent regressions. Signed-off-by: Ilya Leoshkevich Message-ID: <20241108145237.37377-2-iii@linux.ibm.com> Signed-off-by: Richard Henderson --- tests/tcg/multiarch/sigreturn-sigmask.c | 51 +++++++++++++++++++++++++ tests/tcg/multiarch/Makefile.target | 3 ++ 2 files changed, 54 insertions(+) create mode 100644 tests/tcg/multiarch/sigreturn-sigmask.c diff --git a/tests/tcg/multiarch/sigreturn-sigmask.c b/tests/tcg/multiarch/sigreturn-sigmask.c new file mode 100644 index 0000000000..e6cc904898 --- /dev/null +++ b/tests/tcg/multiarch/sigreturn-sigmask.c @@ -0,0 +1,51 @@ +/* + * Test that sigreturn() does not corrupt the signal mask. + * Block SIGUSR2 and handle SIGUSR1. + * Then sigwait() SIGUSR2, which relies on it remaining blocked. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include +#include +#include + +int seen_sig = -1; + +static void signal_func(int sig) +{ + seen_sig = sig; +} + +static void *thread_func(void *arg) +{ + kill(getpid(), SIGUSR2); + return NULL; +} + +int main(void) +{ + struct sigaction act = { + .sa_handler = signal_func, + }; + pthread_t thread; + sigset_t set; + int sig; + + assert(sigaction(SIGUSR1, &act, NULL) == 0); + + assert(sigemptyset(&set) == 0); + assert(sigaddset(&set, SIGUSR2) == 0); + assert(sigprocmask(SIG_BLOCK, &set, NULL) == 0); + + kill(getpid(), SIGUSR1); + assert(seen_sig == SIGUSR1); + + assert(pthread_create(&thread, NULL, thread_func, NULL) == 0); + assert(sigwait(&set, &sig) == 0); + assert(sig == SIGUSR2); + assert(pthread_join(thread, NULL) == 0); + + return EXIT_SUCCESS; +} diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index 78b83d5575..18d3cf4ae0 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -42,6 +42,9 @@ munmap-pthread: LDFLAGS+=-pthread vma-pthread: CFLAGS+=-pthread vma-pthread: LDFLAGS+=-pthread +sigreturn-sigmask: CFLAGS+=-pthread +sigreturn-sigmask: LDFLAGS+=-pthread + # The vma-pthread seems very sensitive on gitlab and we currently # don't know if its exposing a real bug or the test is flaky. ifneq ($(GITLAB_CI),)