X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=bin%2Fblhc;h=c4443832eff00b2552fcf4c1f94468775b6a9c35;hb=f1ac73364a8d0a20e279328db6b6e1e8dbfe9a4e;hp=26826f07a0abe87740087d16b1a3b63e8233b59f;hpb=766e4499437c6e872cc5870a821c4d10d2d8a63b;p=blhc%2Fblhc.git diff --git a/bin/blhc b/bin/blhc index 26826f0..c444383 100755 --- a/bin/blhc +++ b/bin/blhc @@ -237,6 +237,9 @@ my @def_cflags_stack_bad = ( '-fno-stack-protector-all', '-fno-stack-protector-strong', ); +my @def_cflags_stack_clash = ( + '-fstack-clash-protection', +); my @def_cflags_pie = ( '-fPIE', ); @@ -280,6 +283,7 @@ my @flag_refs = ( \@def_cflags_stack, \@def_cflags_stack_strong, \@def_cflags_stack_bad, + \@def_cflags_stack_clash, \@def_cflags_pie, \@def_cxxflags, \@def_cppflags, @@ -802,6 +806,7 @@ foreach my $file (@ARGV) { my $harden_fortify = 1; my $harden_stack = 1; my $harden_stack_strong = 1; + my $harden_stack_clash = 1; my $harden_relro = 1; my $harden_bindnow = $option_bindnow; # defaults to 0 my $harden_pie = $option_pie; # defaults to 0 @@ -856,6 +861,7 @@ foreach my $file (@ARGV) { my $disable = 1; my $disable_strong = 1; + my $disable_clash = 1; if ($line =~ /\bdpkg-dev_(\S+)/) { if (Dpkg::Version::version_compare($1, '1.16.1') >= 0) { @@ -867,6 +873,9 @@ foreach my $file (@ARGV) { if (Dpkg::Version::version_compare($1, '1.18.15') >= 0) { $disable_harden_pie = 1; } + if (Dpkg::Version::version_compare($1, '1.22.0') >= 0) { + $disable_clash = 0; + } } if ($disable) { @@ -880,6 +889,9 @@ foreach my $file (@ARGV) { if ($disable_strong) { $harden_stack_strong = 0; } + if ($disable_clash) { + $harden_stack_clash = 0; + } } # The following two versions of CMake in Debian obeyed CPPFLAGS, but @@ -1195,6 +1207,7 @@ foreach my $file (@ARGV) { i386 kfreebsd-amd64 kfreebsd-i386 + loong64 mips mips64 mips64el @@ -1217,21 +1230,24 @@ foreach my $file (@ARGV) { ); # Disable unsupported hardening options. - if ($os !~ /^(?:linux|kfreebsd|knetbsd|hurd)$/ or $cpu eq 'hppa') { + if ($disable_harden_pie and exists $builtin_pie_arch{$arch}) { + $harden_pie = 0; + } + if ($os !~ /^(?:linux|kfreebsd|hurd)$/ + or $cpu =~ /^(?:alpha|hppa|ia64)$/) { $harden_pie = 0; } if ($cpu =~ /^(?:ia64|alpha|hppa|nios2)$/ or $arch eq 'arm') { $harden_stack = 0; $harden_stack_strong = 0; } + if ($arch !~ /^(?:amd64|arm64|armhf|armel)$/) { + $harden_stack_clash = 0; + } if ($cpu =~ /^(?:ia64|hppa)$/) { $harden_relro = 0; $harden_bindnow = 0; } - - if ($disable_harden_pie and exists $builtin_pie_arch{$arch}) { - $harden_pie = 0; - } } # Default values. @@ -1252,6 +1268,10 @@ foreach my $file (@ARGV) { @cflags = (@cflags, @def_cflags_stack); @cxxflags = (@cxxflags, @def_cflags_stack); } + if ($harden_stack_clash) { + @cflags = (@cflags, @def_cflags_stack_clash); + @cxxflags = (@cxxflags, @def_cflags_stack_clash); + } if ($harden_fortify) { @cflags = (@cflags, @def_cflags_fortify); @cxxflags = (@cxxflags, @def_cflags_fortify);