Commit Graph

72 Commits

Author SHA1 Message Date
Brent Cook
dcb97d12a4 use alternate cflags on AIX and HP-UX vendor compilers 2015-04-19 14:55:25 -05:00
Brent Cook
2753f5ca87 Revert configure-time checks for -Wall/-std=gnu99
There is a problem with these on some compilers, revert while a solution
is found.
2015-04-14 22:12:52 -05:00
Brent Cook
5cf05de18c make compiler checks for -Wall and -std=gnu99
Yes, there are compilers that do not understand or need these.
2015-04-14 08:45:47 -05:00
Brent Cook
3096ab0e45 remove issetuigid wrappers, now that all getenv calls are gone.
From deraadt@ upstream:

Remove all getenv() calls, especially those wrapped by issetugid().
getenv()'s wrapped by issetugid() are safe, but issetugid() is ...
difficult to impliment on many operating systems.  By accident, a grand
experiment was run over the last year, where issetugid() returned 1 (the
safe value) on a few operating systems.  Noone noticed & complained that
certain environment variables were not working.......
2015-04-14 07:55:23 -05:00
Brent Cook
fe3f7fc636 Add experimental AIX support.
This includes a WIP failsafe issetugid for now, while research continues
on the proper way to do this in a race-free fashion in AIX.
2015-03-31 09:25:21 -05:00
Brent Cook
34bf96ce4b move define to CPPFLAGS 2015-03-22 08:14:27 -05:00
Brent Cook
569177eabd Merged support for using _OPENBSD_SOURCE on NetBSD 8.x 2015-03-22 08:11:53 -05:00
Brent Cook
ad2a38ab4a rework CFLAGS/CPPFLAGS settings during configuration
Move define adjustments to CPPFLAGS.
Adjust user CFLAGS directly, do not override during configuration.
USER_CFLAGS is not necessary to build libcompat_noopt correctly.
2015-03-22 07:43:55 -05:00
Brent Cook
809fcf4ea7 move clang flags adjustment next to the check, fix typo 2015-03-22 06:06:40 -05:00
Brent Cook
4106a08da9 check for build tools earlier in configuration 2015-03-22 06:06:40 -05:00
Brent Cook
dcf31221ef Merge native cygwin support 2015-03-21 19:08:04 -05:00
Brent Cook
45065de1ba rework tests Makefile.am
There are so many test exceptions that need handling that it is easier
to simply edit it directly rather than doing autogeneration anymore.

This also puts biotest and pidwraptest behind a new --enable-extratests
option, so they are easy to run but are not enabled by default.
2015-03-21 19:04:54 -05:00
Brent Cook
dd646a3302 enable libtls by default
The API/ABI for the LibreSSL 2.1.x series is now fixed, so we can safely
enable libtls it by default. This is useful for new OpenNTPD and
OpenSMTPD releases as well.

ok deraadt@ beck@ sthen@
2015-03-19 00:39:50 -05:00
Brent Cook
73329d4311 update __STRICT_ALIGNMENT check 2015-03-08 22:02:54 -05:00
Brent Cook
031f0aaa8f specify -static-libgcc for mingw builds
Avoid external external dependencies on 32-bit windows builds.
2015-03-08 22:02:19 -05:00
Kamil Rytarowski
bbf021e11c Reuse _OPENBSD_SOURCE namespace on NetBSD (>=8.x) 2015-03-08 01:35:20 +00:00
Brent Cook
213eb9465e avoid doubling user-specified cflags 2015-03-07 12:02:57 -06:00
Corinna Vinschen
9cad5993a2 Drop test for adding -lssp again, not required with latest libtool
Signed-off-by: Corinna Vinschen <github@cygwin.de>
2015-03-03 18:39:31 +01:00
Corinna Vinschen
98902539a4 Add preliminary Cygwin support
Signed-off-by: Corinna Vinschen <github@cygwin.de>
2015-03-03 16:37:23 +01:00
Brent Cook
933820a0f5 separate the BSWAP check from the action
checks need to be unconditional with autoconf
2015-03-01 16:30:23 -06:00
Brent Cook
8695b50688 check if the BSWAP assembly for ARM works before building 2015-03-01 15:57:21 -06:00
Brent Cook
ab0d3e54a2 add windows-specific hardening options
This enables DEP and ALSR capabilities. Stack protection is enabled
optionally, there are some extra linking steps required that make it
difficult to enable by default.
2015-02-24 19:39:16 -06:00
Brent Cook
347c03d3a0 remove openat requirement for building certhash 2015-02-23 09:48:04 -06:00
Brent Cook
49d80f0e89 add missing line continuation 2015-02-19 21:16:55 -06:00
Brent Cook
a859b93ff5 disable system issetugid on OS X since it is not fork-safe
Noticed while testing similar code for AIX.
ok beck@
2015-02-17 18:15:17 -06:00
Brent Cook
ad7ac48d03 add strsep fallback for libtls 2015-02-14 20:03:39 -06:00
Brent Cook
28311d4355 conditionally build certhash into openssl(1)
For now, look for openat and symlink. We may switch to just needing
symlink later.
2015-02-14 18:54:43 -06:00
Brent Cook
a223365127 add NetBSD shims for arc4random
The current NetBSD release, 6.1.5, fails to reseed arc4random fork. Work
around it by providing arc4random/getentropy shims. Revisit when NetBSD
7 is available.
2015-01-21 06:14:24 -06:00
Brent Cook
ec81c28219 catch GCC versions that only warn on unused flags
Noticed while building with GCC 4.2 with HP-UX. Switching the ERROR to a
WARN for a first release while we continue to survey the field.
2015-01-06 17:47:16 -06:00
Brent Cook
f2d68c7d21 remove bash-style comparisons from tests 2015-01-06 17:47:16 -06:00
kinichiro
0308b63cbf Add support for HP-UX
tested on: HP-UX 11.31 ia64,
               gcc 4.7.1(HP AllianceOne version)
               gcc 4.2.3(http://hpux.connect.org.uk)
	       HP C/aC++

HP-UX defaults to use LP32 and it treats long as 32 bit (= 4 bytes).
This build forces LP64 for treating long as 64 bit.
2015-01-06 17:47:16 -06:00
Brent Cook
4b7e78153c quoting and ensure old_*flags are restored before the 'else' 2015-01-05 21:22:36 -06:00
Brent Cook
872ecfd856 preserve CFLAGS between hardening checks, enable mingw
Allow hardening CFLAGS for mingw that do not cause link-time failures.
Add proper quoting on flags for commas
Check LDFLAGS for linker-only flags.
2015-01-05 20:59:53 -06:00
Brent Cook
303b972d55 simplify hardening check logic, disable for mingw
Rather than doing separate linker/compiler checks, just build a
non-empty program with each so that the compiler will actually try to
use the hardening features. Reduce redundancy in the macro calls by just
setting the flag that was just tested.

Also, disable hardening for mingw, since its trying to use a
libssp-0.dll file that I can't find right now. The detected hardening
flags break mingw builds currently.
2015-01-05 20:23:48 -06:00
Jim Barlow
813e7bdac1 Change comments to remark on script not being needed for clang >= 5.1 2015-01-01 15:03:03 -08:00
Jim Barlow
701204bf34 Fix typo causing output of clang test to read "CLANG" instead of yes/no 2014-12-31 07:06:49 -08:00
Jim Barlow
2dc0a6ac3c Merge recent upstream changes with compiler hardening
Conflicts:
	configure.ac
2014-12-30 15:13:19 -08:00
Brent Cook
23c90228ac enable __STRICT_ALIGNMENT on sparc 2014-12-27 16:34:02 -06:00
Jim Barlow
a6c072343a configure.ac: use executable hardening where available
Where available, enable stack smashing protection, fortify source,
no-strict-overflow, and read only relocations.

Many Linux distributions automatically enable most of these options.
They are no brainers. The difference introduced here is in asking for a
few more aggressive options. An option to disable the more aggressive
options is provided (--disable-hardening). When set, configure will fall
back to the default CFLAGS on the system - in many cases that will still
be hardened. There is no point in going further than that.

Options enabled are:

-fstack-protector-strong is a relatively new GCC-4.9 feature that is
supposed to give a better balance between performance and protection.
-all is considered too aggressive, but was used in Chromium and other
security critical systems until -strong became available. Follow their
lead and use -strong when possible. clang 6.0 supports -all but not
-strong.

_FORTIFY_SOURCE replaces certain unsafe C str* and mem* functions with
more robust equivalents when the compiler can determine the length of
the buffers involved.

-fno-strict-overflow instructs GCC to not make optimizations based on
the assumption that signed arithmetic will wrap around on overflow (e.g.
(short)0x7FFF + 1 == 0). This prevents the optimizer from doing some
unexpected things. Further improvements should trap signed overflows and
reduce the use of signed to refer to naturally unsigned quantities.

I did not set -fPIE (position independent executables). The critical
function of Open/LibreSSL is as a library, not an executable.

Tested on Ubuntu Linux 14.04.1 LTS, OS X 10.10.1 with "make check".

Signed-off-by: Jim Barlow <jim@purplerock.ca>
2014-12-23 05:24:24 -08:00
Jim Barlow
164f684eb8 configure.ac: Modify clang check to save result to a variable
...and leave a note that -Qunused-arguments is being applied to CFLAGS
not LDFLAGS, probably in error.
2014-12-23 04:38:43 -08:00
Brent Cook
04158cd40e do not mark GNU_STACK WX in ELFs generated from assembly
When generating ELF objects from assembly, gcc and clang mark the
GNU_STACK program headers as RWX by default. This is a security issue,
so we make sure it is marked only RW.

This modifies Anthony G. Basile's original patch for Linux to set
.note.GNU-stack whenever the assembler supports it. It is surprising
that any modern toolchain would enable an executable stack without an
explicit request. The number of programs that need an executable stack
is surely much smaller than the number of programs that include assembly.
2014-12-22 23:04:47 -06:00
Brent Cook
d2342f36bc allow Windows DLLs to be built
based on a patch from Jan Engelhardt
2014-12-14 16:59:35 -06:00
Brent Cook
03cd45e2c7 Enable optimized crypto operations for x86_64
This adds initial support for assembly crypto acceleration on x86_64 for
ELF (Linux, *BSD, Solaris) and Mach-O (OS-X) systems.

The build method is a little different than OpenSSL and OpenBSD.  All
the .s files are generated ahead of time when the tarball is generated,
so there are no complicated makefile rules at configure/build time. This
also means the builds are faster and perl is not required on the build
system.

Thanks to Wouter Clarie for providing the initial cleanup and patch
that this is based on.
2014-12-07 16:26:28 -06:00
Brent Cook
976f64d932 read all library versions directly from files
This makes building and testing easier because the library Makefile.am
files are use directly rather than as templates. Thanks to Wouter Clarie
for the idea.
2014-12-06 18:59:25 -06:00
Brent Cook
b3270494f0 add support for building libtls
Use './configure --enable-libtls' to build the library and install the
associated manpages. Note that the API and ABI of this library may
change still, though feedback is welcome.

ok deraadt@ jsing@ tedu@
2014-12-06 09:13:56 -06:00
Brent Cook
1bbde19a7c add minimal poll(2) implementation for Windows
This provides sufficient functionality to run openssl(1) from a Windows
console. This is based on the original select-based version from from
songdongsheng@live.cn. Changes:

 * use nfds_t directly for iterating the fds.
 * add WSAGetLastError -> errno mappings
 * handle POLLHUP and the OOB data cases for revents
 * handle sparse arrays of fds correctly
 * KNF style updates
 * teach poll how to handle file handles as well as sockets

This handles the socket/non-socket issue  by alternating a loop between
WaitForMultipleObjects for non-sockets and and select for sockets. One
would think this would be terrible for performance, but as of this
writing, poll consumes about 6% of the time doing a bulk transfer
between a Linux box and 'openssl.exe s_server'.

I tried to implement this all in terms of WaitForMultipleObjects with a
select 'poll' at the end to get extra specific socket status. However,
the cost of setting up an event handle for each socket, setting the
WSAEventSelect attributes, and cleaning them up reliably was pretty
high. Since the event handle associated with a socket is also global,
creating a new one cancels the previous one or can be disabled
externally.

In addition, the 'FD_WRITE' status of a socket event handle does not
behave in an expected fashion, being triggered by an edge on a write
event rather than being level triggered.

Another fun horror story is how stdin in windows might be a console, it
might be a pipe, it might be something else. If these all worked in the
same way, it would be great. But, since a console-stdin can also signal
on a mouse or window event, it means we can easily get stuck in a
blocking read (you can't make stdin non-blocking) if the non-character
events are not filtered out. So, poll does that too.

See here for various additional horror stories:

http://www.postgresql.org/message-id/4351.1336927207@sss.pgh.pa.us
2014-12-03 17:03:47 -06:00
Brent Cook
7f0646f612 Update win32 build defines 2014-12-03 17:02:29 -06:00
Brent Cook
d84aa5cbc1 Quiet clang warnings about unused arguments in general.
Check if we are using clang, rather than simply if we are on OS X.
Note: recent LLVM releases do not seem to need this anyway.
2014-11-03 21:06:40 -06:00
Brent Cook
94ec2b6b1c make 'autoreconf' work from dist tarball
We need to include VERSION for it to run.
2014-11-03 21:05:47 -06:00
Brent Cook
0aeb93b9fc override native arc4random_buf on FreeBSD
The FreeBSD-native arc4random_buf implementation falls back to weak
sources of entropy if the sysctl fails. Remove these dangerous fallbacks
by overriding locally.

Unfortunately, pthread_atfork() is broken on FreeBSD (at least 9 and 10)
if a program does not link to -lthr. Callbacks registered with
pthread_atfork() simply fail silently. So, it is not always possible to
detect a PID wraparound. I wish we could do better.

This improves arc4random_buf's safety compared to the native FreeBSD
implementation. Tested on FreeBSD 9 and 10.

ok beck@ deraadt@
2014-11-03 01:19:36 -06:00