From patchwork Tue Sep 10 12:22:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 826978 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp274615wrc; Tue, 10 Sep 2024 05:23:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU//LD9xVOoFGSqQl6PtQmS2cLhHH9lcu7EPrsXHOlvMMq8GHLhdKGc5gsqd1Ajj5jv00WrCQ==@linaro.org X-Google-Smtp-Source: AGHT+IHPpEwBs+Q5GenSUPXTJYVjbzbcB4CKeBwclOBt5RKG1ULEXDIvhVOVGUhYcPS+kw2A7/rU X-Received: by 2002:a05:6214:3da1:b0:6c3:550a:c7c9 with SMTP id 6a1803df08f44-6c528511fb7mr177238916d6.50.1725970987653; Tue, 10 Sep 2024 05:23:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1725970987; cv=pass; d=google.com; s=arc-20240605; b=VkOa+GROVJeffD0G/Wp2qEDI4kx2FSPWT9hYKoSfSpqdVGacBjGXY7I6lJOr4hY+QI KgNu2mr9vxGc/iO61BLTAq/hSbanfg84896uYawtDfQ7pwGGPHZzX+vA0OnmgqdG90bh 5QGKJA3pW7IwCwnfddhwZgKL7ZKev0qA7AHMWjKHxqEZdNSB8N3iKoed5yY2YakSJavO BV/yAYuO6DypFxI1i/Q3aFSOqrgV1wKIZb5Kj/sw0R6R20F+hu8oeQ+2GODpbNiHntcM vGT2SsiJTTxYRXWZU1Icwa5jZpRpfn3u+W1nn6Cf46fPRY4zB98MMZKzHveBFeOcj24Z GrCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=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:arc-filter:dmarc-filter:delivered-to; bh=EzZppli2BnvgT/iaWeHdGp9ma4zFlejRE7n6olisXYc=; fh=lvhpNY6+SHq89AyVt6fa8bkVWGNbJmFPkAi6n1fTc1c=; b=ahNXmwiEdSFxHGl3a+q84BTptUjk/l3K4THMX4rAPaQ+mjCvjRLVk54DWYlhCc6rrq CCO+McKf+ganX9UFIhGRcNX/fk94OL0Fbnv91uHUujQE0jQqoPxxu33rgX16g1B6wVIS xoe33nnd7VNK/o4yXZo6gVC+l77olhUAfTjtsukmn2cIyksNvIng6TEZx+AR7BcZ+Ivk xtVpdxWPMOr96MKoC94n8BKyQOyai1DNc1BJG3lQUhXz/QM4eSFdA5XlrOxGeq9TtUc+ /0dylKdEJ6ZjMR6HLYmzwc7l7d7no+jzKmvP1R96wMaziX4/Wy9FZM6qiGt/F/P+WqFK SIsw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fWHq5FqI; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 6a1803df08f44-6c5347c2fadsi77200646d6.537.2024.09.10.05.23.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 05:23:07 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fWHq5FqI; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EF5D93858435 for ; Tue, 10 Sep 2024 12:23:06 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id B9803385B508 for ; Tue, 10 Sep 2024 12:22:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9803385B508 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B9803385B508 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725970976; cv=none; b=Ipdr0Q26f7uaR+QLYEeLVUfaY+92ezqU/Y+rFV7KGZSlFrRz5tLK5FSEYl/OiG3fh0FItjq4UPGrvsbaC1zj5f7INC+dueQSsL67R+9Fkq7HZL/EiacpBXsV+KZKK5VcsLzeI3LT6bU9DZ97N58BuOnVCN5j5VpMuCs/s0/11Uk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725970976; c=relaxed/simple; bh=CJqHvk6qe1//nTarDUJ8FUNpsp4k+cPfsaZsMY9Amqk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=LoM2pbdb+QS3Ks7b41tikcqit85EpVoBRvBPYckk2qJQ1xWTBHmZpF2b85gsxGLHbbChnVh9KKTvZFyFabdfxaYtYQgmCi7G9ICvBH+Ec9j+b3HH/iUUdm+ZPZ17SCGFK0aNou9C3GQ7AgtYcfOA5QwqclcMotyJLi0vKOffpcU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-2d8f06c2459so3519051a91.0 for ; Tue, 10 Sep 2024 05:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725970973; x=1726575773; darn=sourceware.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=EzZppli2BnvgT/iaWeHdGp9ma4zFlejRE7n6olisXYc=; b=fWHq5FqIzEufEwF9t/9N+nAr+Tv5nHP1jP3UvWs1mitgLe3bvlbWX/bYwrd0i+98Ng yosKvlCeJKz0kjeci+BzFYOD4tM9lZbH9oBGVD9DMOMES8ckenBDHIx7/JDlUG3M/MhN 9pxVwO4vg8PEOTKJJfBSnNZ5S2j1Ty1PMoRky1yKveaACOQFpwLUbZGe52V4swKH82MW KPsN0LEntDvHHiCcSvKDhVu3bPnY7Sr6Ju0IQRqJybm/zCksfEs9MF2LLf0uNMVpS9bg uMDPhfl1bSOx/aB6P2jn/XGar0hQjIjNTJw+QAjNfyE+eQGz5XX0N5r84nCkIl7pUuuA +J7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725970973; x=1726575773; 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=EzZppli2BnvgT/iaWeHdGp9ma4zFlejRE7n6olisXYc=; b=PJ8VV5K2kv8oQSXf64hcK+SN5zShzvoZbinrhzc29QX3+eRQJ6B2xhfL2EzOhi8Xvv bC7Iwp0YNqoiLo42Z71DC6g2diNJxM0ElPm+nWqzSEW7LODXdivT8Ph6yodt0pmiYhJF 2AdUpUe/PemQ+9xqVGwmp1ML+7+Xjl16fL0z1CWzANbs+S3G39VfO/rAMKj38zToQLqh 2cLFuRciK4F7wsKk9rNnnSM/FYOh7xQqCGkqt80Gfc2iWJNx6R1Hqz4Daaz891BJ4hD+ RzeKja7thbNvdbuCOo2ttOjk3Ybp8iTi7YBBZVtLPBcsKG5fK50rBkj6lgwlPhuGG78Y zpEA== X-Gm-Message-State: AOJu0YzamW1S8lQm2rvtUayDhKuJGAX6q9nLdroUJhgH8g3e2oZ+1Lx+ YAiVd7n0JdXa9an8gL0/u+cslwOrHMccCQJCsfUbyQptOSjPJPKZas6t6m2FELU5Jnm6SPLc529 t X-Received: by 2002:a17:90a:77ca:b0:2d8:8ead:f013 with SMTP id 98e67ed59e1d1-2dad4efdfa9mr13492302a91.7.1725970973332; Tue, 10 Sep 2024 05:22:53 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:80ff:f471:9688:94c:da67]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db6dca2773sm552804a91.1.2024.09.10.05.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 05:22:52 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Simon Chopin , Matthias Klose Subject: [PATCH 1/3] Do not use -Wp to disable fortify (BZ 31928) Date: Tue, 10 Sep 2024 09:22:17 -0300 Message-ID: <20240910122244.1995107-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240910122244.1995107-1-adhemerval.zanella@linaro.org> References: <20240910122244.1995107-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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~patch=linaro.org@sourceware.org The -Wp does not work properly if the compiler is configured to enable fortify by default, since it bypasses the compiler driver (which defines the fortify flags in this case). This patch is similar to the one used on Ubuntu [1]. I checked with a build for x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, s390x-linux-gnu, and riscv64-linux-gnu with gcc-13 that enables the fortify by default. Co-authored-by: Matthias Klose [1] https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/glibc/tree/debian/patches/ubuntu/fix-fortify-source.patch --- configure | 4 ++-- configure.ac | 4 ++-- debug/Makefile | 19 ++++++++++--------- io/Makefile | 2 +- stdio-common/Makefile | 2 +- wcsmbs/Makefile | 2 +- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/configure b/configure index ec0b62db36..58bfb2917f 100755 --- a/configure +++ b/configure @@ -7718,7 +7718,7 @@ printf "%s\n" "#define HAVE_LIBCAP 1" >>confdefs.h fi -no_fortify_source="-Wp,-U_FORTIFY_SOURCE" +no_fortify_source="-U_FORTIFY_SOURCE" fortify_source="${no_fortify_source}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for maximum supported _FORTIFY_SOURCE level" >&5 @@ -7773,7 +7773,7 @@ esac if test "$libc_cv_fortify_source" = yes then : - fortify_source="${fortify_source},-D_FORTIFY_SOURCE=${enable_fortify_source}" + fortify_source="${fortify_source} -D_FORTIFY_SOURCE=${enable_fortify_source}" fi diff --git a/configure.ac b/configure.ac index 7c9b57789e..5af742ce41 100644 --- a/configure.ac +++ b/configure.ac @@ -1536,7 +1536,7 @@ dnl If not, then don't use it. dnl Note that _FORTIFY_SOURCE may have been set through FLAGS too. dnl _FORTIFY_SOURCE value will be selectively disabled for function that can't dnl support it -no_fortify_source="-Wp,-U_FORTIFY_SOURCE" +no_fortify_source="-U_FORTIFY_SOURCE" fortify_source="${no_fortify_source}" AC_CACHE_CHECK([for maximum supported _FORTIFY_SOURCE level], @@ -1555,7 +1555,7 @@ AS_CASE([$enable_fortify_source], [libc_cv_fortify_source=no]) AS_IF([test "$libc_cv_fortify_source" = yes], - [fortify_source="${fortify_source},-D_FORTIFY_SOURCE=${enable_fortify_source}"] + [fortify_source="${fortify_source} -D_FORTIFY_SOURCE=${enable_fortify_source}"] ) AC_SUBST(enable_fortify_source) diff --git a/debug/Makefile b/debug/Makefile index 3903cc97a3..89ee80bf4d 100644 --- a/debug/Makefile +++ b/debug/Makefile @@ -171,16 +171,16 @@ CFLAGS-recvfrom_chk.c += -fexceptions -fasynchronous-unwind-tables # set up for us, so keep the CFLAGS/CPPFLAGS split logical as the order is: # CFLAGS-tst-longjmp_chk.c += -fexceptions -fasynchronous-unwind-tables -CPPFLAGS-tst-longjmp_chk.c += $(no-fortify-source),-D_FORTIFY_SOURCE=1 +CPPFLAGS-tst-longjmp_chk.c += $(no-fortify-source) -D_FORTIFY_SOURCE=1 CFLAGS-tst-longjmp_chk2.c += -fexceptions -fasynchronous-unwind-tables -CPPFLAGS-tst-longjmp_chk2.c += $(no-fortify-source),-D_FORTIFY_SOURCE=1 +CPPFLAGS-tst-longjmp_chk2.c += $(no-fortify-source) -D_FORTIFY_SOURCE=1 CFLAGS-tst-longjmp_chk3.c += -fexceptions -fasynchronous-unwind-tables -CPPFLAGS-tst-longjmp_chk3.c += $(no-fortify-source),-D_FORTIFY_SOURCE=1 -CPPFLAGS-tst-realpath-chk.c += $(no-fortify-source),-D_FORTIFY_SOURCE=2 -CPPFLAGS-tst-chk-cancel.c += $(no-fortify-source),-D_FORTIFY_SOURCE=2 -CFLAGS-tst-sprintf-fortify-rdonly.c += $(no-fortify-source),-D_FORTIFY_SOURCE=2 -CFLAGS-tst-fortify-syslog.c += $(no-fortify-source),-D_FORTIFY_SOURCE=2 -CFLAGS-tst-fortify-wide.c += $(no-fortify-source),-D_FORTIFY_SOURCE=2 +CPPFLAGS-tst-longjmp_chk3.c += $(no-fortify-source) -D_FORTIFY_SOURCE=1 +CPPFLAGS-tst-realpath-chk.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2 +CPPFLAGS-tst-chk-cancel.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2 +CFLAGS-tst-sprintf-fortify-rdonly.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2 +CFLAGS-tst-fortify-syslog.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2 +CFLAGS-tst-fortify-wide.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2 # _FORTIFY_SOURCE tests. # Auto-generate tests for _FORTIFY_SOURCE for different levels, compilers and @@ -218,7 +218,8 @@ src-chk-nongnu = \#undef _GNU_SOURCE # cannot be disabled via pragmas, so require -Wno-error to be used. define gen-chk-test tests-$(1)-$(4)-chk += tst-fortify-$(1)-$(2)-$(3)-$(4) -CFLAGS-tst-fortify-$(1)-$(2)-$(3)-$(4).$(1) += $(no-fortify-source),-D_FORTIFY_SOURCE=$(3) -Wno-format \ +CFLAGS-tst-fortify-$(1)-$(2)-$(3)-$(4).$(1) += $(no-fortify-source) -D_FORTIFY_SOURCE=$(3) \ + -Wno-format \ -Wno-deprecated-declarations \ -Wno-error $(eval $(call cflags-$(2),$(1),$(3),$(4))) diff --git a/io/Makefile b/io/Makefile index 47666a1deb..56de61d687 100644 --- a/io/Makefile +++ b/io/Makefile @@ -292,7 +292,7 @@ CFLAGS-read.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-i CFLAGS-write.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-ignored-attributes) CFLAGS-close.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-lseek64.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-tst-read-zero.c += $(no-fortify-source),-D_FORTIFY_SOURCE=$(supported-fortify) +CFLAGS-tst-read-zero.c += $(no-fortify-source) -D_FORTIFY_SOURCE=$(supported-fortify) CFLAGS-test-stat.c += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE CFLAGS-test-lfs.c += -D_LARGEFILE64_SOURCE diff --git a/stdio-common/Makefile b/stdio-common/Makefile index d99e0cbfeb..f9ae48dc3b 100644 --- a/stdio-common/Makefile +++ b/stdio-common/Makefile @@ -558,7 +558,7 @@ CFLAGS-tst-gets.c += -Wno-deprecated-declarations # BZ #11319 was first fixed for regular vdprintf, then reopened because # the fortified version had the same bug. -CFLAGS-tst-bz11319-fortify2.c += $(no-fortify-source),-D_FORTIFY_SOURCE=2 +CFLAGS-tst-bz11319-fortify2.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2 CFLAGS-tst-memstream-string.c += -fno-builtin-fprintf diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile index 63adf0e8ef..37a44e62c3 100644 --- a/wcsmbs/Makefile +++ b/wcsmbs/Makefile @@ -264,7 +264,7 @@ CFLAGS-wcstod_l.c += $(strtox-CFLAGS) $(config-cflags-wno-ignored-attributes) CFLAGS-wcstold_l.c += $(strtox-CFLAGS) $(config-cflags-wno-ignored-attributes) CFLAGS-wcstof128_l.c += $(strtox-CFLAGS) CFLAGS-wcstof_l.c += $(strtox-CFLAGS) $(config-cflags-wno-ignored-attributes) -CPPFLAGS-tst-wchar-h.c += $(no-fortify-source),-D_FORTIFY_SOURCE=2 +CPPFLAGS-tst-wchar-h.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2 CFLAGS-wcschr.c += $(config-cflags-wno-ignored-attributes) CFLAGS-wmemchr.c += $(config-cflags-wno-ignored-attributes)