t/logs/buildd-dpkg-dev-old
t/logs/buildd-dpkg-fstack-protector
t/logs/buildd-dpkg-fstack-protector-missing
+t/logs/buildd-gcc-pie
+t/logs/buildd-gcc-pie-builtin
+t/logs/buildd-gcc-pie-builtin-wrong-arch
t/logs/buildd-package-details
t/logs/buildd-verbose-build
t/logs/c++
in non-verbose-build detection, reported by Boud Roukema and Nico Schlömer
(Debian Bug #853265).
- Add better support for Fortran (c.f. Debian Bug #853265).
+- Don't report missing PIE flags in buildd mode if GCC defaults to PIE (c.f.
+ Debian Bug 845339).
Version 0.07
# use a large enough default.
my $parallel = 10;
+ # Don't check for PIE flags if automatically applied by the compiler. Only
+ # used in buildd mode.
+ my $disable_harden_pie = 0;
+
while (my $line = <$fh>) {
# Detect architecture automatically unless overridden. For buildd logs
# only, doesn't use the dpkg-buildpackage header. Necessary to ignore
# flags are not checked.
#
# Strong stack protector is used since dpkg 1.17.11.
+ #
+ # Recent GCC versions automatically use PIE (only on supported
+ # architectures) and dpkg respects this properly since 1.18.15 and
+ # doesn't pass PIE flags manually.
if ($option_buildd
and index($line, 'Toolchain package versions: ') == 0) {
require Dpkg::Version;
if (Dpkg::Version::version_compare($1, '1.17.11') >= 0) {
$disable_strong = 0;
}
+ if (Dpkg::Version::version_compare($1, '1.18.15') >= 0) {
+ $disable_harden_pie = 1;
+ }
}
if ($disable) {
# Option or auto detected.
if ($arch) {
- # The following was partially copied from dpkg-dev 1.18.15
+ # The following was partially copied from dpkg-dev 1.18.24
# (/usr/share/perl5/Dpkg/Vendor/Debian.pm, _add_hardening_flags()),
# copyright Raphaël Hertzog <hertzog@debian.org>, Kees Cook
# <kees@debian.org>, Canonical, Ltd. licensed under GPL version 2 or
(undef, $os, $cpu) = Dpkg::Arch::debarch_to_debtriplet($arch);
}
+ my %builtin_pie_arch = map { $_ => 1 } qw(
+ amd64 arm64 armel armhf i386 kfreebsd-amd64 kfreebsd-i386
+ mips mipsel mips64el ppc64el s390x sparc sparc64
+ );
+
# Disable unsupported hardening options.
if ($os !~ /^(?:linux|kfreebsd|knetbsd|hurd)$/
or $cpu =~ /^(?:hppa|avr32)$/) {
$harden_relro = 0;
$harden_bindnow = 0;
}
+
+ if ($disable_harden_pie and exists $builtin_pie_arch{$arch}) {
+ $harden_pie = 0;
+ }
}
# Default values.
--- /dev/null
+Toolchain package versions: ... dpkg-dev_1.18.14 ...
+dpkg-buildpackage: source package foo package
+dpkg-buildpackage: host architecture amd64
+
+gcc -g -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now -fstack-protector-strong -Wformat -Werror=format-security -o test test.c
--- /dev/null
+Toolchain package versions: ... dpkg-dev_1.18.15 ...
+dpkg-buildpackage: source package foo package
+dpkg-buildpackage: host architecture amd64
+
+gcc -g -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now -fstack-protector-strong -Wformat -Werror=format-security -o test test.c
+gcc -fPIE -pie -g -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now -fstack-protector-strong -Wformat -Werror=format-security -o test test.c
--- /dev/null
+Toolchain package versions: ... dpkg-dev_1.18.15 ...
+dpkg-buildpackage: source package foo package
+dpkg-buildpackage: host architecture ia64
+
+gcc -g -O2 -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now -fstack-protector-strong -Wformat -Werror=format-security -o test test.c
use strict;
use warnings;
-use Test::More tests => 218;
+use Test::More tests => 226;
sub is_blhc {
'W-dpkg-buildflags-missing|CFLAGS 3 (of 6), CXXFLAGS 1 (of 1) missing|
';
+is_blhc 'buildd-gcc-pie', '--buildd --all', 0,
+ 'W-dpkg-buildflags-missing|CFLAGS 1 (of 1), LDFLAGS 1 (of 1) missing|
+';
+is_blhc 'buildd-gcc-pie-builtin-wrong-arch', '--buildd --all', 0,
+ 'W-dpkg-buildflags-missing|CFLAGS 1 (of 1), LDFLAGS 1 (of 1) missing|
+';
+is_blhc 'buildd-gcc-pie-builtin', '--buildd', 0, '';
+is_blhc 'buildd-gcc-pie-builtin', '--buildd --all', 0, '';
+
# Older dpkg versions use -fstack-protector instead of -strong.
is_blhc 'buildd-dpkg-fstack-protector', '--buildd', 0,
'';