From patchwork Sun Jan 4 20:42:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 127365 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 6A6DF4BA2E26 for ; Sun, 4 Jan 2026 20:43:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A6DF4BA2E26 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 63C1F4BA2E05 for ; Sun, 4 Jan 2026 20:42:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 63C1F4BA2E05 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 63C1F4BA2E05 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1767559359; cv=none; b=BKQW2OZ4nNCYyDwHgD1x7qdQz5dhKHFysXFMign1ztnaKdQjB5WSO3PyH26xS8K7RG5OT6PBcHnc7SZPyN6UOVbY23g/nD+GhzhO9CBKX8iaTgKM5VwRsg+rk0cTUNCAcceQrFKqM/2+Yb+AOC0/EcN+qM/vjWW27S27jD7yIc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1767559359; c=relaxed/simple; bh=lF0iAuqMytp2nnlnV/dx2xKPODvebRG/01Km2lbjScY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=G98babIcWUguodZXgj4bLYmigO6v6vl3H/kBS+CxfW6TDCJPwuDmOcjqvFb9HEHbJ+pneG05aRq9no700AtIbCm4YGTsxVRY+ymuGBsLIivI4L1JiVLg60GAOeRfN+K8l1q/4VAWYXOmPuA5zieH/cP5bKI7WE+t+Ms95CGKGJ8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63C1F4BA2E05 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 56F21A01E9; Sun, 4 Jan 2026 21:42:38 +0100 (CET) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R_47pKnO-5Kr; Sun, 4 Jan 2026 21:42:38 +0100 (CET) Received: from end (aamiens-653-1-40-48.w83-192.abo.wanadoo.fr [83.192.199.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 3C61DA017D; Sun, 4 Jan 2026 21:42:38 +0100 (CET) Received: from samy by end with local (Exim 4.99.1) (envelope-from ) id 1vcUvs-0000000DjgV-36CB; Sun, 04 Jan 2026 21:42:36 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd, commited] hurd: check that signal processing does not hurt the x86_64 redzone Date: Sun, 4 Jan 2026 21:42:35 +0100 Message-ID: <20260104204235.3273847-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org --- sysdeps/mach/hurd/x86_64/Makefile | 5 + sysdeps/mach/hurd/x86_64/tst-sig-redzone.c | 109 +++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 sysdeps/mach/hurd/x86_64/tst-sig-redzone.c diff --git a/sysdeps/mach/hurd/x86_64/Makefile b/sysdeps/mach/hurd/x86_64/Makefile index 2b43f5d625..270705ac66 100644 --- a/sysdeps/mach/hurd/x86_64/Makefile +++ b/sysdeps/mach/hurd/x86_64/Makefile @@ -4,6 +4,11 @@ ifeq ($(subdir),conform) conformtest-xfail-conds += x86_64-gnu endif +ifeq ($(subdir),hurd) +tests += tst-sig-redzone +$(objpfx)tst-sig-redzone: $(shared-thread-library) +endif + ifeq ($(subdir),stdlib) sysdep_routines += __start_context endif diff --git a/sysdeps/mach/hurd/x86_64/tst-sig-redzone.c b/sysdeps/mach/hurd/x86_64/tst-sig-redzone.c new file mode 100644 index 0000000000..0855bd6900 --- /dev/null +++ b/sysdeps/mach/hurd/x86_64/tst-sig-redzone.c @@ -0,0 +1,109 @@ +/* Test the redzone is not affected during signal handling. + + Copyright (C) 2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +static volatile atomic_bool startflag = ATOMIC_VAR_INIT (false); +static volatile atomic_bool loopflag = ATOMIC_VAR_INIT (true); + +void handler (int signum, siginfo_t *info, void *context) +{ + char buf[128]; + memset (buf, 0x77, sizeof buf); + printf ("signal %d hurting stack a bit\n", signum); + atomic_store_explicit (&loopflag, false, memory_order_release); +} + +/* Helper thread to send a signal to the main thread */ +void* signal_sender (void *arg) +{ + sigset_t ss; + assert (! sigemptyset (&ss)); + assert (! sigaddset (&ss, SIGUSR1)); + assert (! sigprocmask (SIG_BLOCK, &ss, NULL)); + + while (!atomic_load_explicit (&startflag, memory_order_acquire)) + ; + TEST_COMPARE (kill (getpid (), SIGUSR1), 0); + + return NULL; +} + +static int do_test (void) +{ + struct sigaction act = { 0 }; + act.sa_sigaction = &handler; + TEST_COMPARE (sigaction (SIGUSR1, &act, NULL), 0); + + pthread_t thsender = xpthread_create (NULL, signal_sender, NULL); + + int check_redzone (void); + TEST_COMPARE (check_redzone (), 0); + + xpthread_join (thsender); + return EXIT_SUCCESS; +} + +asm ( +"check_redzone:\n" + +" movabs $0x3333333333333333, %rax\n" +" mov $(128/8), %ecx\n" +" lea -128(%rsp), %rdi\n" +"rep stosq\n" + +" movl $1, startflag(%rip)\n" +"wait:\n" +" cmpl $0, loopflag(%rip)\n" +" jne wait\n" + +" movabs $0x3333333333333333, %rax\n" +" mov $(128/8), %ecx\n" +" lea -128(%rsp), %rdi\n" +"repe scasq\n" +" jne fail\n" + +" xor %rax,%rax\n" +" ret\n" +"fail:\n" +" movq $1,%rax\n" +" ret\n" +); + +#include