[master] 9d04b55 Disable ASLR if -spersistent is configured.

Poul-Henning Kamp phk at FreeBSD.org
Fri Nov 25 23:06:05 CET 2016


commit 9d04b5577356a05de7bf299487c679307bc189b4
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Nov 25 22:03:58 2016 +0000

    Disable ASLR if -spersistent is configured.
    
    This should stabilize r00962 on Ubuntu and make -spersistent less
    useless on same.

diff --git a/bin/varnishd/storage/mgt_storage_persistent.c b/bin/varnishd/storage/mgt_storage_persistent.c
index f55d793..f5cd350 100644
--- a/bin/varnishd/storage/mgt_storage_persistent.c
+++ b/bin/varnishd/storage/mgt_storage_persistent.c
@@ -50,6 +50,10 @@
 
 #include "storage/storage_persistent.h"
 
+#ifdef HAVE_SYS_PERSONALITY_H
+#include <sys/personality.h>
+#endif
+
 #ifndef MAP_NOCORE
 #define MAP_NOCORE 0 /* XXX Linux */
 #endif
@@ -139,6 +143,18 @@ smp_mgt_init(struct stevedore *parent, int ac, char * const *av)
 
 	AZ(av[ac]);
 
+
+#ifdef HAVE_SYS_PERSONALITY_H
+	i = personality(0xffffffff); /* Fetch old personality. */
+	if (!(i & ADDR_NO_RANDOMIZE)) {
+		i = personality(i | ADDR_NO_RANDOMIZE);
+		if (i < 0)
+			fprintf(stderr, "WARNING: Could not disable ASLR\n");
+		else
+			fprintf(stderr, "NB: Disabled ASLR for Persistent\n");
+	}
+#endif
+
 	/* Necessary alignment. See also smp_object::__filler__ */
 	assert(sizeof(struct smp_object) % 8 == 0);
 
diff --git a/configure.ac b/configure.ac
index bfc0099..bbbe55b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -206,6 +206,7 @@ AC_CHECK_HEADERS([sys/types.h])
 AC_CHECK_HEADERS([sys/endian.h])
 AC_CHECK_HEADERS([sys/filio.h])
 AC_CHECK_HEADERS([sys/mount.h], [], [], [#include <sys/param.h>])
+AC_CHECK_HEADERS([sys/personality.h])
 AC_CHECK_HEADERS([sys/socket.h])
 AC_CHECK_HEADERS([sys/statvfs.h])
 AC_CHECK_HEADERS([sys/vfs.h])



More information about the varnish-commit mailing list