From patchwork Thu Feb 15 22:53:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam James X-Patchwork-Id: 1899851 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=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.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 4TbVq54Ynvz23hR for ; Fri, 16 Feb 2024 09:58:40 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C9623386D63A for ; Thu, 15 Feb 2024 22:58:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 53EE0386D604 for ; Thu, 15 Feb 2024 22:58:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 53EE0386D604 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 53EE0386D604 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.211.166.183 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708037900; cv=none; b=FnPdTfY7QuK2Nq0+2rTc9QD7H/BwmrqcaE7RkJQrYarH/nTXvZPrILii5QI0eqWz9sc4Qylt8/JP6LogpbK19ShPrg3N4LpbnypEk/STtDoZuTLi6RcqcHSsZ/jvXLhTmSOVpDJyADL4nAOdufzuyAKASa+qZ/rvgzn4Qw293GM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708037900; c=relaxed/simple; bh=CYHRDW0wLG14oZ1tlmdQSZg16Gcp04ydFiOEtfkzVgo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=jjs6gGH2zfAnmzo+ZB3LU+INdATCr0wWvD2ivJvaF1KjwY+on1j7zPlvelpWIC2k44ybea/4meH43mHUkHYYWxSANkehkzbv6Wxl78ezUmNhNwBFKFi3DgNKCXNf2gpBwf7r65W6aGy1mUmjBH0XpZWkYUYwU0D8FfsEDJxtKak= ARC-Authentication-Results: i=1; server2.sourceware.org From: Sam James To: gcc-patches@gcc.gnu.org Cc: Jakub Jelinek , Marek Polacek , Sam James Subject: [PATCH] testsuite: Fix vfprintf-chk-1.c with -fhardened Date: Thu, 15 Feb 2024 22:53:08 +0000 Message-ID: <20240215225806.2836388-1-sam@gentoo.org> X-Mailer: git-send-email 2.43.1 MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org With _FORTIFY_SOURCE >= 2 (enabled by -fhardened), vfprintf-chk-1.c's __vfprintf_chk ends up calling __vprintf_chk rather than vprintf. ``` #ifndef test +#undef _FORTIFY_SOURCE #include #include #include --- a/fortify.s +++ b/no-fortify.s @@ -8,27 +8,28 @@ [...] __vfprintf_chk: [...] movl $1, should_optimize(%rip) - jmp __vfprintf_chk + jmp vfprintf@PLT ``` 2024-02-15 Sam James gcc/testsuite/ChangeLog: * gcc.c-torture/execute/vfprintf-chk-1.c (__vfprintf_chk): Undefine _FORTIFY_SOURCE to call the real vfprintf. --- The test, AIUI, is trying to test GCC's own basic _chk bits rather than any of e.g. glibc's _FORTIFY_SOURCE handling. I'm curious as to why only vfprintf triggers this right now. If this patch is right, perhaps we should do printf-chk-1.c, fprintf-chk-1.c, and vprintf-chk-1. Please push if OK as I don't have access. gcc/testsuite/gcc.c-torture/execute/vfprintf-chk-1.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/testsuite/gcc.c-torture/execute/vfprintf-chk-1.c b/gcc/testsuite/gcc.c-torture/execute/vfprintf-chk-1.c index 401eaf4304a4..a8e5689e3fe6 100644 --- a/gcc/testsuite/gcc.c-torture/execute/vfprintf-chk-1.c +++ b/gcc/testsuite/gcc.c-torture/execute/vfprintf-chk-1.c @@ -1,6 +1,7 @@ /* { dg-skip-if "requires io" { freestanding } } */