From: Craig Lorentzen Date: Mon, 1 Apr 2024 15:49:44 +0000 (-0400) Subject: Security hardening: Expose Build flags for Position Independed Execution (PIE) X-Git-Tag: openssl-3.4.0-alpha1~591 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c4f9684696bad3a602b388a414f2051f0365b3d;p=thirdparty%2Fopenssl.git Security hardening: Expose Build flags for Position Independed Execution (PIE) Reviewed-by: Tom Cosgrove Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/22596) --- diff --git a/.github/workflows/run-checker-merge.yml b/.github/workflows/run-checker-merge.yml index e5746d75bdf..8a1da0c2f2a 100644 --- a/.github/workflows/run-checker-merge.yml +++ b/.github/workflows/run-checker-merge.yml @@ -35,6 +35,7 @@ jobs: no-ts, enable-weak-ssl-ciphers, enable-zlib, + enable-pie, ] runs-on: ubuntu-latest steps: diff --git a/CHANGES.md b/CHANGES.md index 21fd185444d..1258a44b523 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -59,6 +59,13 @@ OpenSSL 3.4 *Damian Hobson-Garcia* + * Added support to build Position Independent Executables (PIE). Configuration + option `enable-pie` configures the cflag '-fPIE' and ldflag '-pie' to + support Address Space Layout Randomization (ASLR) in the openssl executable, + removes reliance on external toolchain configurations. + + *Craig Lorentzen* + OpenSSL 3.3 ----------- diff --git a/Configurations/00-base-templates.conf b/Configurations/00-base-templates.conf index 55da5ec56c2..a9ccb0ced87 100644 --- a/Configurations/00-base-templates.conf +++ b/Configurations/00-base-templates.conf @@ -76,6 +76,22 @@ my %targets=( AR => "ar", ARFLAGS => "qc", CC => "cc", + bin_cflags => + sub { + my @flags = (); + if (!defined($disabled{pie})) { + push(@flags, "-fPIE"); + } + return join(" ", @flags); + }, + bin_lflags => + sub { + my @flags = (); + if (!defined($disabled{pie})) { + push(@flags, "-pie"); + } + return join(" ", @flags); + }, lflags => sub { my @libs = (); diff --git a/Configure b/Configure index cef9e8c3e66..f7fc016c8ca 100755 --- a/Configure +++ b/Configure @@ -492,6 +492,7 @@ my @disablables = ( "ocsp", "padlockeng", "pic", + "pie", "pinshared", "poly1305", "posix-io", @@ -584,6 +585,7 @@ our %disabled = ( # "what" => "comment" "external-tests" => "default", "fuzz-afl" => "default", "fuzz-libfuzzer" => "default", + "pie" => "default", "ktls" => "default", "md2" => "default", "msan" => "default", @@ -943,6 +945,10 @@ while (@argvcopy) { delete $disabled{"brotli"}; } + elsif ($1 eq "pie") + { + delete $disabled{"pie"}; + } elsif ($1 eq "zstd-dynamic") { delete $disabled{"zstd"}; diff --git a/INSTALL.md b/INSTALL.md index b486ee1556a..a34de9bbf8c 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -870,6 +870,10 @@ As synonym for `no-padlockeng`. Deprecated and should not be used. Don't build with support for Position Independent Code. +### enable-pie + +Build with support for Position Independent Execution. + ### no-pinshared Don't pin the shared libraries.