]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
dhcpcd: disable address sanitization by default
authorRoy Marples <roy@marples.name>
Tue, 31 Mar 2020 19:21:58 +0000 (20:21 +0100)
committerRoy Marples <roy@marples.name>
Tue, 31 Mar 2020 19:21:58 +0000 (20:21 +0100)
As recent production kernels ship with ASLR by default which
stops dhcpcd running dead when this is enabled.
We dont want to break a systems boot, so force it via configure.

configure

index a8932d33a6de1c3ef24ad67989b6dbad72f9185b..de0bf3f2505848c97caa137ad788c038f285fa78 100755 (executable)
--- a/configure
+++ b/configure
@@ -34,6 +34,7 @@ EMBEDDED=
 AUTH=
 POLL=
 SMALL=
+SANITIZE=no
 STATUSARG=
 
 DHCPCD_DEFS=dhcpcd-definitions.conf
@@ -104,6 +105,7 @@ for x do
        --with-udev) DEV=yes; UDEV=yes;;
        --without-udev) UDEV=no;;
        --with-poll) POLL="$var";;
+       --sanitize) SANITIZEADDRESS="yes";;
        --serviceexists) SERVICEEXISTS=$var;;
        --servicecmd) SERVICECMD=$var;;
        --servicestatus) SERVICESTATUS=$var;;
@@ -382,21 +384,6 @@ if [ -z "$DEBUG" -a -d .git ]; then
 fi
 if [ -n "$DEBUG" -a "$DEBUG" != no -a "$DEBUG" != false ]; then
        echo "Adding debugging CFLAGS"
-       printf "Testing compiler supports address sanitisation ..."
-       cat <<EOF >_test.c
-int main(void) {
-       return 0;
-}
-EOF
-       if $CC -fsanitize=address _test.c -o _test 2>&3; then
-               echo "yes"
-               echo "# Compiler supports address sanitisation" >>$CONFIG_MK
-               echo "CFLAGS+=  -fsanitize=address" >>$CONFIG_MK
-               echo "LDFLAGS+= -fsanitize=address" >>$CONFIG_MK
-       else
-               echo "no"
-       fi
-       rm -rf _test.c _test
 
        cat <<EOF >>$CONFIG_MK
 CFLAGS+=       -g -Wall -Wextra -Wundef
@@ -408,6 +395,7 @@ CFLAGS+=    -Wcast-qual -Wwrite-strings
 CFLAGS+=       -Wformat=2
 CFLAGS+=       -Wpointer-sign -Wmissing-noreturn
 EOF
+
        case "$OS" in
        mirbsd*|openbsd*);; # OpenBSD has many redundant decs in system headers
        bitrig*|solaris*|sunos*)
@@ -428,6 +416,23 @@ EOF
        case "$CC" in
        *gcc*)          echo "CFLAGS+=  -Wlogical-op" >>$CONFIG_MK;;
        esac
+
+       if [ "$SANITIZEADDRESS" = yes ]; then
+               printf "Testing compiler supports address sanitisation ..."
+       cat <<EOF >_test.c
+int main(void) {
+       return 0;
+}
+EOF
+               if $CC -fsanitize=address _test.c -o _test 2>&3; then
+                       echo "yes"
+                       echo "CFLAGS+=  -fsanitize=address" >>$CONFIG_MK
+                       echo "LDFLAGS+= -fsanitize=address" >>$CONFIG_MK
+               else
+                       echo "no"
+               fi
+               rm -rf _test.c _test
+       fi
 else
        echo "CPPFLAGS+=        -DNDEBUG" >>$CONFIG_MK
 fi