From patchwork Thu Jul 18 18:43:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 1962202 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WQ1sv2npnz1ySl for ; Fri, 19 Jul 2024 04:43:47 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 18D593858C66 for ; Thu, 18 Jul 2024 18:43:45 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from dellerweb.de (dellerweb.de [173.249.48.176]) by sourceware.org (Postfix) with ESMTPS id 1F70B3858CDA for ; Thu, 18 Jul 2024 18:43:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1F70B3858CDA Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=mx3210.local Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=parisc-linux.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1F70B3858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=173.249.48.176 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721328210; cv=none; b=TqYKVEYmWPUuqQZrlIfv0+Yot4qIOXjmq88aqwdeqjOT13QYX3HfusnVj0c2O2wHuL6Q6rWO6ohLdEnk22RaUT2qXMzfERnQc7BTsXE4M51/m8aULEn+H+7zTa4WYxFXwFED6fUm/naIxPJMCg5tLWFwDyeSV23QP3QwBqGSwVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721328210; c=relaxed/simple; bh=TuoUb1AcgQdsP9yO+MjWo2dPsRozp8n6wFLx9HNgXbw=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=wL+reS9tKE9UC7j4+9sglzem9O2qxC9TRVerIipGVokSP/AxSkPY4Br1ZDZJGCQx2C2HT5Nys4Rw0BhfxiFobEq/ZcjlJmu+qjEGwqYUas96PGtZ15ccG3BY4bcLfrJayEkLMcC72wM/azgYI5YhWEIT8ENPcyF602H8ImD+jII= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from mx3210.localdomain (unknown [174.88.98.220]) by dellerweb.de (Postfix) with ESMTPSA id 07C001600165; Thu, 18 Jul 2024 20:43:27 +0200 (CEST) Received: by mx3210.localdomain (Postfix, from userid 1000) id 071A5D6014E; Thu, 18 Jul 2024 14:43:24 -0400 (EDT) Date: Thu, 18 Jul 2024 14:43:24 -0400 From: John David Anglin To: libc-alpha@sourceware.org Cc: Helge Deller Subject: [PATCH] Fix usage of _STACK_GROWS_DOWN and _STACK_GROWS_UP defines [BZ 31989] Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_ADSP_NXDOMAIN, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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~incoming=patchwork.ozlabs.org@sourceware.org When When glibc is configured with --enable-fortify-source, the stdlib/tst-swapcontext2 test fails on hppa. The stack placement for func1 and func2 are interchanged causing the test to fail. The attached patch fixes several places where the defines for _STACK_GROWS_UP and_STACK_GROWS_DOWN are used. Both are defined on all targets, so using #ifdef is incorrect. Tested on hppa-unknown-linux-gnu with no regressions. Okay for trunk? I know we are in the freeze for 2.40 release. Dave Reviewed-by: Sam James Reviewed-by: Carlos O'Donell --- Fix usage of _STACK_GROWS_DOWN and _STACK_GROWS_UP defines [BZ 31989] diff --git a/malloc/memusage.c b/malloc/memusage.c index e8ae80dc74..f80225b95a 100644 --- a/malloc/memusage.c +++ b/malloc/memusage.c @@ -172,7 +172,7 @@ update_data (struct header *result, size_t len, size_t old_len) start_sp = __thread_stack_pointer (); uintptr_t sp = __thread_stack_pointer (); -#ifdef _STACK_GROWS_UP +#if _STACK_GROWS_UP /* This can happen in threads where we didn't catch the thread's stack early enough. */ if (__glibc_unlikely (sp < start_sp)) diff --git a/stdlib/tst-swapcontext2.c b/stdlib/tst-swapcontext2.c index f679755649..a9c1dc827c 100644 --- a/stdlib/tst-swapcontext2.c +++ b/stdlib/tst-swapcontext2.c @@ -85,7 +85,7 @@ do_test (void) { /* ____longjmp_chk has */ #if 0 -#ifdef _STACK_GROWS_DOWN +#if _STACK_GROWS_DOWN #define called_from(this, saved) ((this) < (saved)) #else #define called_from(this, saved) ((this) > (saved)) @@ -98,7 +98,7 @@ do_test (void) /* Arrange stacks for uctx_func1 and uctx_func2 so that called_from is true when setjmp is called from uctx_func1 and longjmp is called from uctx_func2. */ -#ifdef _STACK_GROWS_DOWN +#if _STACK_GROWS_DOWN # define UCTX_FUNC1_STACK 1 # define UCTX_FUNC2_STACK 0 #else diff --git a/sysdeps/unix/sysv/linux/____longjmp_chk.c b/sysdeps/unix/sysv/linux/____longjmp_chk.c index 0896dc5755..3c66a4638e 100644 --- a/sysdeps/unix/sysv/linux/____longjmp_chk.c +++ b/sysdeps/unix/sysv/linux/____longjmp_chk.c @@ -23,7 +23,7 @@ #include #include -#ifdef _STACK_GROWS_DOWN +#if _STACK_GROWS_DOWN #define called_from(this, saved) ((this) < (saved)) #else #define called_from(this, saved) ((this) > (saved))