Commit Graph

194 Commits

Author SHA1 Message Date
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
Brent Cook
5be407a424 move public domain to top, help automatic tools 2015-01-02 07:42:15 -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
750cc5306d Fix build failure of "make distcheck" (new scripts/ folder missing) 2014-12-31 07:17:47 -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
9adc6d6458 Revert "do not double-link libcrypto"
This reverts commit c83d468cfd.
It wasn't as superfluous as I thought on all platforms.
2014-12-27 16:52:25 -06:00
Brent Cook
c83d468cfd do not double-link libcrypto
libssl already has LIBFLAGS for libcrypto, so adding -lcrypto is superfluous.
2014-12-27 16:34:48 -06:00
Brent Cook
23c90228ac enable __STRICT_ALIGNMENT on sparc 2014-12-27 16:34:02 -06:00
Jim Barlow
c0a8ddc163 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".

The code added to m4/ is GPLv3 but con

Signed-off-by: Jim Barlow <jim@purplerock.ca>
2014-12-23 21:47:03 -08: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
Technion
8c6c07c5ba Add wrapper file "config" to distribution. 2014-12-15 07:43:17 +00:00
Brent Cook
56f7523337 enable OS X and Linux CI builds 2014-12-14 21:03:38 -06:00
Brent Cook
733c252857 add Travis CI configuration 2014-12-14 20:46:14 -06:00
Brent Cook
c2dccc1418 add all LIBADD dependencies for tls
The libtool transitive dependency magic does not seem to work for
cross-compilation, so explicitly specify them here.
2014-12-14 20:38:02 -06:00
Brent Cook
a29b174e31 bump version
append portable version number to the version string
2014-12-14 17:12:50 -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
09e5a841cd add LIBADD library dependencies to libssl/libtls
From Jan Engelhardt
2014-12-14 16:59:35 -06:00
Brent Cook
2669771c7e Use the individual library versions in LibreSSL pc files
Previously, they were all using the portable package version, rather
than the individual library versions. openssl(1)'s pc file represents
the LibreSSL-portable release however.

$ pkg-config --modversion libtls
1:0:0
$ pkg-config --modversion openssl
2.1.2
$ pkg-config --modversion libssl
30:0:0
$ pkg-config --modversion libcrypto
30:3:0

ok beck@ deraadt@
2014-12-14 16:59:26 -06:00
Brent Cook
cfa0445115 don't hardcode a fixed # of jobs for make 2014-12-08 18:35:22 -06:00
Brent Cook
722b48f044 update libtls URL
thanks to gschutijser from github for pointing it out
2014-12-08 18:34:06 -06:00
Brent Cook
cfbc62e686 update and rework changelog for readability 2014-12-07 22:24:03 -06:00
Brent Cook
6f6ca9dcf0 use the new $MV macro to generate assembly files
Avoid spurious rebuilds running update.sh by generating a temp file and
comparing the result to the existing one.
2014-12-07 18:50:58 -06:00
Brent Cook
5109e657df use 'make distcheck' for the release build script 2014-12-07 18:16:16 -06:00
Dmitry Eremin-Solenikov
a270e6a90b tests/Makefile.am.tpl: remove generated files on distclean
Add pidwraptest.txt to DISTCLEANFILES to let it be removed on distclean.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
2014-12-07 18:07:53 -06:00
Dmitry Eremin-Solenikov
afcd515b99 update.sh: remove linked manpages on uninstall
Add additional code to remove linked manpages on uninstall. Since we do
linking manually, automake will not remove them for us.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
2014-12-07 18:07:53 -06:00
Dmitry Eremin-Solenikov
9d70cdc60d update.sh: add MV-like function preserving file timestamps
Add a do_mv()/$MV wrappers to be called instead of just mv. This
function will preserve the target file if it does not differ from the
source file. This helps to remove unnecessary compilator calls after
calling update.sh w/o source changes.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
2014-12-07 18:07:53 -06:00
Dmitry Eremin-Solenikov
5390bbea3e update.sh: call $CP instead of cp to ease rebuilds
In several additional places call $CP instead of just cp to ease and
speed up rebuilds after update.sh execution.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
2014-12-07 18:07:52 -06:00
Dmitry Eremin-Solenikov
a40fccc73b Update .gitignore
Add gost test suite and camellia cipher dir to .gitignore.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
2014-12-07 18:07:52 -06:00
Dmitry Eremin-Solenikov
7842cda3c8 update.sh: include gost test suite
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
2014-12-07 18:07:52 -06:00
Brent Cook
9c685415ab disable inline assembly on Windows for now
There are issues building with inline assembly on Windows 64-bit.
2014-12-07 18:02:06 -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
e57d5d8be3 sync man links from upstream
I really need write something to automate this.
2014-12-07 13:12:41 -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
14f4175b67 split long manpage makefile lines. 2014-12-06 17:48:03 -06:00
Brent Cook
29804a73cc simplify packaging for libcrypto.
Remove a lot of complex shell code. Upstream churn has slowed down, so
it is now easier to maintain this directly as automake files. This is
also needed to start integrating CPU-specific acceleration support.

Since we are deriving the copy list from the Makefile.am files, we can
now get rid of copy_src/copy_crypto.
2014-12-06 17:48:03 -06:00
Brent Cook
605acdcef2 remove obsolete define 2014-12-06 17:47:44 -06:00
Brent Cook
d643bcf4b5 simplify packaging for libssl.
Follow libtls and derive the file list from the Makefile.am
template itself.
2014-12-06 17:47:30 -06:00
Brent Cook
13035fa666 simplify building the apps Makefile
Remove extra machinery in favor of a plain-old Makefile.am.
Tighten up what files are copied on build, package a simple openssl.cnf.
2014-12-06 11:20:56 -06:00
Brent Cook
33ff088a60 simplify packaging for libtls.
Derive the file list from the Makefile.am template itself (DRY), ensure
manpage is packaged with the final tarball.
2014-12-06 10:21:23 -06:00
Brent Cook
d3ea95b9f5 update changelog for libtls 2014-12-06 09:29:22 -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
fc5e43c32b update changelog for 2.1.2 2014-12-03 23:11:08 -06:00
Brent Cook
a19dd0e61b better cleanup biotest.c 2014-12-03 22:58:24 -06:00
Brent Cook
e83c30c158 monkey patch more POSIX-like behavior out of winsock 2
Windows sockets functions look on the outside like they behave similarly
to POSIX functions, but there are many subtle and glaring differences,
including errors reported via WSAGetLastError, read, write, and close do
not work on sockets, setsockopt takes a (char *) rather than (void *),
etc.

This header implements wrappers that coerce more POSIX-like behavior
from these functions, making portable code easier to develop.

BENEFITS:
One does not necessarily need to sprinkle #ifdefs around code to handle
the Windows and non-Windows behavior when porting code.

CAVEATS:
There may be performance implications with the 'mother-may-I'
approach to determining if a descriptor is a socket or a file.

The errno mappings are not 100% what one might expect compared to POSIX
since there were not always good 1:1 equivalents from the WSA errors.
2014-12-03 17:07:17 -06:00
Brent Cook
cccdd689e3 add minimal winsock->BSD networking header shims
also add license header to existing shims
2014-12-03 17:07:17 -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