Date: Thu, 26 Sep 2019 15:50:19 +0000 (UTC) From: Ed Maste <emaste@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r352752 - in stable/12: share/mk tools/build/options Message-ID: <201909261550.x8QFoJXY056485@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: emaste Date: Thu Sep 26 15:50:18 2019 New Revision: 352752 URL: https://svnweb.freebsd.org/changeset/base/352752 Log: Add a WITH_BIND_NOW build knob MFC r340186: 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. MFC r341429: disable BIND_NOW in libc, libthr, and rtld An issue remains with BIND_NOW and processes using threads. For now, restore libc's BIND_NOW disable, and also disable BIND_NOW in rtld and libthr. MFC r345625: revert r341429 "disable BIND_NOW in libc, libthr, and rtld" r345620 by kib@ fixed the rtld issue that caused a crash at startup during resolution of libc's ifuncs with BIND_NOW. MFC r345638: Revert change accidentally committed along with r345625 MFC r345640: Revert other accidentally committed part of r345625 Sponsored by: The FreeBSD Foundation Added: stable/12/tools/build/options/WITHOUT_BIND_NOW - copied unchanged from r340186, head/tools/build/options/WITHOUT_BIND_NOW stable/12/tools/build/options/WITH_BIND_NOW - copied unchanged from r340186, head/tools/build/options/WITH_BIND_NOW Modified: stable/12/share/mk/bsd.lib.mk stable/12/share/mk/bsd.opts.mk stable/12/share/mk/bsd.prog.mk Directory Properties: stable/12/ (props changed) Modified: stable/12/share/mk/bsd.lib.mk ============================================================================== --- stable/12/share/mk/bsd.lib.mk Thu Sep 26 15:41:10 2019 (r352751) +++ stable/12/share/mk/bsd.lib.mk Thu Sep 26 15:50:18 2019 (r352752) @@ -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 Modified: stable/12/share/mk/bsd.opts.mk ============================================================================== --- stable/12/share/mk/bsd.opts.mk Thu Sep 26 15:41:10 2019 (r352751) +++ stable/12/share/mk/bsd.opts.mk Thu Sep 26 15:50:18 2019 (r352752) @@ -69,6 +69,7 @@ __DEFAULT_YES_OPTIONS = \ WARNS __DEFAULT_NO_OPTIONS = \ + BIND_NOW \ CCACHE_BUILD \ CTF \ INSTALL_AS_USER \ Modified: stable/12/share/mk/bsd.prog.mk ============================================================================== --- stable/12/share/mk/bsd.prog.mk Thu Sep 26 15:41:10 2019 (r352751) +++ stable/12/share/mk/bsd.prog.mk Thu Sep 26 15:50:18 2019 (r352752) @@ -34,6 +34,10 @@ PROG= ${PROG_CXX} MK_DEBUG_FILES= no .endif +# ELF hardening knobs +.if ${MK_BIND_NOW} != "no" +LDFLAGS+= -Wl,-znow +.endif .if ${MK_RETPOLINE} != "no" CFLAGS+= -mretpoline CXXFLAGS+= -mretpoline Copied: stable/12/tools/build/options/WITHOUT_BIND_NOW (from r340186, head/tools/build/options/WITHOUT_BIND_NOW) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/tools/build/options/WITHOUT_BIND_NOW Thu Sep 26 15:50:18 2019 (r352752, copy of r340186, head/tools/build/options/WITHOUT_BIND_NOW) @@ -0,0 +1,5 @@ +.\" $FreeBSD$ +Do not build all binaries with the +.Dv DF_BIND_NOW +flag set. +Run-time relocation processing will be performed on demand. Copied: stable/12/tools/build/options/WITH_BIND_NOW (from r340186, head/tools/build/options/WITH_BIND_NOW) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/tools/build/options/WITH_BIND_NOW Thu Sep 26 15:50:18 2019 (r352752, copy of r340186, head/tools/build/options/WITH_BIND_NOW) @@ -0,0 +1,5 @@ +.\" $FreeBSD$ +Build all binaries with the +.Dv DF_BIND_NOW +flag set to indicate that the run-time loader should perform all relocation +processing at process startup rather than on demand.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909261550.x8QFoJXY056485>