[v2,13/13] configure: Build with _FORTIFY_SOURCE by default

Message ID 20261030173000.3245502-14-adhemerval.zanella@linaro.org (mailing list archive)
State Under Review
Delegated to: DJ Delorie
Headers
Series elf: Add loader hardening tunables |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed

Commit Message

Adhemerval Zanella Oct. 30, 2026, 5:27 p.m. UTC
  The default is now the highest level supported by the compiler, as with
--enable-fortify-source: 3 if __builtin_dynamic_object_size is
available, which is the case for every supported GCC version, and 2
otherwise.  --disable-fortify-source builds without fortification.

Checked on x86_64-linux-gnu.
---
 INSTALL             | 4 +++-
 NEWS                | 5 +++++
 configure           | 4 ++--
 configure.ac        | 7 ++++---
 manual/install.texi | 3 ++-
 5 files changed, 16 insertions(+), 7 deletions(-)
  

Patch

diff --git a/INSTALL b/INSTALL
index 7d49b8fd2f3..3555fc4f26e 100644
--- a/INSTALL
+++ b/INSTALL
@@ -273,7 +273,9 @@  passed to 'configure'.  For example:
      Library.  If not provided, 'LEVEL' defaults to highest possible
      value supported by the build compiler.
 
-     Default is to disable fortification.
+     Fortification is enabled by default, at the highest level supported
+     by the build compiler.  Use '--disable-fortify-source' to disable
+     it.
 
 '--enable-sframe'
      Experimental option supported by some architectures, where the GNU
diff --git a/NEWS b/NEWS
index e948cd342ea..034b8fd03b8 100644
--- a/NEWS
+++ b/NEWS
@@ -61,6 +61,11 @@  Changes to build and runtime requirements:
   --enable-stack-protector=strong.  Use --disable-stack-protector to build
   without stack protection.
 
+* The GNU C Library is now built with _FORTIFY_SOURCE by default, at the
+  highest level supported by the compiler, as if configured with
+  --enable-fortify-source.  Use --disable-fortify-source to build without
+  fortification.
+
 Security related changes:
 
 The following CVEs were fixed in this release, details of which can be
diff --git a/configure b/configure
index 323ccc21f8d..7e761272ff6 100755
--- a/configure
+++ b/configure
@@ -1500,7 +1500,7 @@  Optional Features:
   --enable-fortify-source[=1|2|3]
                           Use -D_FORTIFY_SOURCE=[1|2|3] to control code
                           hardening, defaults to highest possible value
-                          supported by the build compiler.
+                          supported by the build compiler. [default=yes]
   --enable-sframe         Enable building with SFrame support [default=no]
 
 Optional Packages:
@@ -4836,7 +4836,7 @@  if test ${enable_fortify_source+y}
 then :
   enableval=$enable_fortify_source; enable_fortify_source=$enableval
 else case e in #(
-  e) enable_fortify_source=no ;;
+  e) enable_fortify_source=yes ;;
 esac
 fi
 
diff --git a/configure.ac b/configure.ac
index f16ea5bb249..632fc93f1db 100644
--- a/configure.ac
+++ b/configure.ac
@@ -402,12 +402,13 @@  AC_ARG_ENABLE([scv],
 
 AS_IF([[test "$use_scv" != "no"]],[AC_DEFINE(USE_PPC_SCV)])
 
-dnl Build glibc with _FORTIFY_SOURCE
+dnl Build glibc with _FORTIFY_SOURCE, by default at the highest level
+dnl supported by the compiler.
 AC_ARG_ENABLE(fortify-source,
               AS_HELP_STRING([--enable-fortify-source@<:@=1|2|3@:>@],
-                             [Use -D_FORTIFY_SOURCE=[1|2|3] to control code hardening, defaults to highest possible value supported by the build compiler.]),
+                             [Use -D_FORTIFY_SOURCE=[1|2|3] to control code hardening, defaults to highest possible value supported by the build compiler. @<:@default=yes@:>@]),
               [enable_fortify_source=$enableval],
-              [enable_fortify_source=no])
+              [enable_fortify_source=yes])
 case "$enable_fortify_source" in
 1|2|3|no|yes) ;;
 *) AC_MSG_ERROR([Not a valid argument for --enable-fortify-source: "$enable_fortify_source"]);;
diff --git a/manual/install.texi b/manual/install.texi
index 4f6594e399d..e741291db58 100644
--- a/manual/install.texi
+++ b/manual/install.texi
@@ -303,7 +303,8 @@  Use -D_FORTIFY_SOURCE=@option{LEVEL} to control hardening in the GNU C Library.
 If not provided, @option{LEVEL} defaults to highest possible value supported by
 the build compiler.
 
-Default is to disable fortification.
+Fortification is enabled by default, at the highest level supported by the
+build compiler.  Use @option{--disable-fortify-source} to disable it.
 
 @item --enable-sframe
 Experimental option supported by some architectures, where @theglibc{}