FreeBSD src
Go to file
Kyle Evans d0fa84f474 ssp: add a priority to the __stack_chk_guard constructor
First, this commit is a NOP on GCC <= 4.x; this decidedly doesn't work
cleanly on GCC 4.2, and it will be gone soon anyways so I chose not to dump
time into figuring out if there's a way to make it work. xtoolchain-gcc,
clocking in as GCC6, can cope with it just fine and later versions are also
generally ok with the syntax. I suspect very few users are running GCC4.2
built worlds and also experiencing potential fallout from the status quo.

For dynamically linked applications, this change also means very little.
rtld will run libc ctors before most others, so the situation is
approximately a NOP for these as well.

The real cause for this change is statically linked applications doing
almost questionable things in their constructors. qemu-user-static, for
instance, creates a thread in a global constructor for their async rcu
callbacks. In general, this works in other places-

- On OpenBSD, __stack_chk_guard is stored in an .openbsd.randomdata section
  that's initialized by the kernel in the static case, or ld.so in the
  dynamic case
- On Linux, __stack_chk_guard is apparently stored in TLS and such a problem
  is circumvented there because the value is presumed stable in the new
  thread.

On FreeBSD, the rcu thread creation ctor and __guard_setup are both unmarked
priority. qemu-user-static spins up the rcu thread prior to __guard_setup
which starts making function calls- some of these are sprinkled with the
canary. In the middle of one of these functions, __guard_setup is invoked in
the main thread and __stack_chk_guard changes- qemu-user-static is promptly
terminated for an SSP violation that didn't actually happen.

This is not an all-too-common problem. We circumvent it here by giving the
__stack_chk_guard constructor a solid priority. 200 was chosen because that
gives static applications ample range (down to 101) for working around it
if they really need to. I suspect most applications will "just work" as
expected- the default/non-prioritized flavor of __constructor__ functions
run last, and the canary is generally not expected to change as of this
point at the very least.

This took approximately three weeks of spare time debugging to pin down.

PR:		241905
2019-11-13 02:14:17 +00:00
bin Add iflag=fullblock to dd 2019-09-30 22:00:48 +00:00
cddl fix zpool list property names 2019-11-07 11:50:53 +00:00
contrib Merge commit 371ea70bb from llvm git (by Louis Dionne): 2019-11-11 17:41:56 +00:00
crypto Merge OpenSSL 1.1.1d. 2019-09-10 21:08:17 +00:00
etc libexecinfo: Integrate NetBSD test into FreeBSD 2019-10-27 05:32:08 +00:00
gnu Get the readline header from the installed header instead of the from the source 2019-09-12 15:50:14 +00:00
include Import OpenSSL 1.1.1d. 2019-09-10 17:40:53 +00:00
kerberos5 Fix generation of krb5-config with LC_CTYPE=*.UTF-8 2019-07-01 11:47:45 +00:00
lib ssp: add a priority to the __stack_chk_guard constructor 2019-11-13 02:14:17 +00:00
libexec libcompat: Correct rtld MLINKS 2019-11-12 22:31:59 +00:00
release Remove picobsd build scripts and the remaining tinyware 2019-11-05 02:30:41 +00:00
rescue Remove unused defines since r147075 2019-07-12 04:44:50 +00:00
sbin makefs: avoid warning when creating FAT filesystem on existing file 2019-11-08 14:11:25 +00:00
secure caroot: commit initial bundle 2019-10-04 02:34:20 +00:00
share Enable the RISC-V LLVM backend by default. 2019-11-12 21:26:50 +00:00
stand reverting r354594 2019-11-12 10:02:39 +00:00
sys Fix a race between daopen and damediapoll 2019-11-13 01:58:43 +00:00
targets - Retire pc-sysinstall(8) 2019-09-03 19:42:04 +00:00
tests Vendor import of file 5.37 2019-11-10 03:44:32 +00:00
tools If /usr/obj is a symlink, cpio(1) needs persuation to DTRT. 2019-11-02 10:15:34 +00:00
usr.bin libcompat: Correct rtld MLINKS 2019-11-12 22:31:59 +00:00
usr.sbin sesutil: fix another memory leak 2019-11-12 23:57:57 +00:00
.arcconfig callsign isn't required anymore 2016-09-29 06:19:45 +00:00
.arclint arc lint: ignore /tests/ in chmod 2017-12-19 03:38:06 +00:00
.cirrus.yml cirrus.yml: stop fetching OVMF.fd now that we're using the pkg 2019-07-30 16:40:33 +00:00
.clang-format Add a basic clang-format configuration file 2019-06-07 15:23:52 +00:00
.gitattributes Add a basic clang-format configuration file 2019-06-07 15:23:52 +00:00
.gitignore .gitignore: Add LINT kernel configurations generated into SRCDIR 2019-08-10 18:22:22 +00:00
COPYRIGHT Happy New Year 2019! 2019-01-01 00:25:25 +00:00
LOCKS LOCKS: update current locks 2018-06-09 03:08:04 +00:00
MAINTAINERS [skip ci] Add me to MAINTAINERS for fusefs 2019-07-28 15:20:47 +00:00
Makefile Take arm.arm (armv5) out of universe 2019-11-03 19:36:34 +00:00
Makefile.inc1 Force MK_CLANG_IS_CC on in XMAKE. 2019-11-12 21:29:52 +00:00
Makefile.libcompat libcompat: build 32-bit rtld and ldd as part of "everything" 2019-11-07 22:58:10 +00:00
Makefile.sys.inc AUTO_OBJ: For all top-level targets enforce using an OBJDIR. 2017-12-05 21:29:47 +00:00
ObsoleteFiles.inc Remove picobsd(8) via make delete-old 2019-11-05 17:33:27 +00:00
README Vendor import of file 5.37 2019-11-10 03:44:32 +00:00
README.md README: add generic notes about GENERIC and NOTES 2018-06-17 19:44:24 +00:00
RELNOTES Document iwm(4) support for 9000-series devices. 2019-11-08 00:01:37 +00:00
UPDATING add a note about nctgpio and wbwd move to superio 2019-11-07 07:21:23 +00:00

FreeBSD Source:

This is the top level of the FreeBSD source directory. This file was last revised on: FreeBSD

FreeBSD is an operating system used to power modern servers, desktops, and embedded platforms. A large community has continually developed it for more than thirty years. Its advanced networking, security, and storage features have made FreeBSD the platform of choice for many of the busiest web sites and most pervasive embedded networking and storage devices.

For copyright information, please see the file COPYRIGHT in this directory. Additional copyright information also exists for some sources in this tree - please see the specific source directories for more information.

The Makefile in this directory supports a number of targets for building components (or all) of the FreeBSD source tree. See build(7), config(8), https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html, and https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html for more information, including setting make(1) variables.

Source Roadmap:

bin		System/user commands.

cddl		Various commands and libraries under the Common Development
		and Distribution License.

contrib		Packages contributed by 3rd parties.

crypto		Cryptography stuff (see crypto/README).

etc		Template files for /etc.

gnu		Various commands and libraries under the GNU Public License.
		Please see gnu/COPYING* for more information.

include		System include files.

kerberos5	Kerberos5 (Heimdal) package.

lib		System libraries.

libexec		System daemons.

release		Release building Makefile & associated tools.

rescue		Build system for statically linked /rescue utilities.

sbin		System commands.

secure		Cryptographic libraries and commands.

share		Shared resources.

stand		Boot loader sources.

sys		Kernel sources.

sys/<arch>/conf Kernel configuration files. GENERIC is the configuration
		used in release builds. NOTES contains documentation of
		all possible entries.

tests		Regression tests which can be run by Kyua.  See tests/README
		for additional information.

tools		Utilities for regression testing and miscellaneous tasks.

usr.bin		User commands.

usr.sbin	System administration commands.

For information on synchronizing your source tree with one or more of the FreeBSD Project's development branches, please see:

https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/current-stable.html