aboutsummaryrefslogtreecommitdiff
path: root/share/mk/bsd.lib.mk
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2018-11-06 15:52:49 +0000
committerEd Maste <emaste@FreeBSD.org>2018-11-06 15:52:49 +0000
commitbf81eb3ca9758d6a45f5a92c0689fcad455827cd (patch)
treec67a90fc01377b4f0d92e950495ae54b5d749d90 /share/mk/bsd.lib.mk
parent02bf7e5e40ddaa79a2089ef221350f35f033c421 (diff)
downloadsrc-bf81eb3ca9758d6a45f5a92c0689fcad455827cd.tar.gz
src-bf81eb3ca9758d6a45f5a92c0689fcad455827cd.zip
Add a WITH_BIND_NOW build knob
The linker's -z now flag sets the DF_BIND_NOW flag, which signals to the runtime loader that all relocation processing should be performed at process startup rather than on demand. In combination with lld's default of enabling relro this causes the GOT to be made read-only when the process starts, preventing straightforward GOT overwrite attacks. Shawn Webb discovered a failure on HardenedBSD with BIND_NOW and ifunc use, which resulted in my rtld fix in r340137. Add a BIND_NOW knob as it is trivial to do so and is a useful ELF hardening feature. This change is equivalent to HardenedBSD's but not identical as there are other diffs/conflicts nearby. Note that our ELF Tool Chain readelf does not currently decode the DF_BIND_NOW flag - see PR232983. Reviewed by: brooks MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D17846
Notes
Notes: svn path=/head/; revision=340186
Diffstat (limited to 'share/mk/bsd.lib.mk')
-rw-r--r--share/mk/bsd.lib.mk4
1 files changed, 4 insertions, 0 deletions
diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index 2dfac241122a..5c1a38ce7ccd 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -69,6 +69,10 @@ TAGS+= package=${PACKAGE:Uruntime}
TAG_ARGS= -T ${TAGS:[*]:S/ /,/g}
.endif
+# ELF hardening knobs
+.if ${MK_BIND_NOW} != "no"
+LDFLAGS+= -Wl,-znow
+.endif
.if ${MK_RETPOLINE} != "no"
CFLAGS+= -mretpoline
CXXFLAGS+= -mretpoline