15991 Commits

Author SHA1 Message Date
Tobias Brunner
83186d3cf7 child-sa: Add new state to track installation of only the inbound SA 2017-05-23 18:41:31 +02:00
Tobias Brunner
4989aba822 child-sa: Change API used to set/install policies
This way we only have to pass the traffic selectors once.
2017-05-23 18:41:31 +02:00
Tobias Brunner
29ef4cf5f4 child-sa: Split in- and outbound policy de-/installation
Only install outbound fallback policies.
2017-05-23 18:41:30 +02:00
Tobias Brunner
b00bcb9add child-create: Trigger NARROW_RESPONDER_POST hook before installing SAs
This makes sure we use the same set of traffic selectors when installing
the SAs and installing the policies.
2017-05-23 18:41:30 +02:00
Tobias Brunner
4cc77142e0 Merge branch 'fuzzing'
Adds support for fuzzing the certificate parser provided by the default
plugins (x509, pem, gmp etc.) on Google's OSS-Fuzz infrastructure (or
generally with libFuzzer). Fixes several issues that were found while
fuzzing these plugins.

When building the libraries monolithically and statically the
plugin constructors are now hard-coded in each library so the plugin
code is not removed by the linker because it thinks none of their symbols
are ever referenced.
2017-05-23 18:38:46 +02:00
Tobias Brunner
a9b698f5be tnc-ifmap: Null-terminate buffer to make sscanf()-calls safe 2017-05-23 18:29:13 +02:00
Tobias Brunner
c001716642 libimcv: Make sure the first argument to sscanf() is null-terminated 2017-05-23 18:29:13 +02:00
Tobias Brunner
411bda6836 asn1: Make sure the first argument to sscanf() is null-terminated 2017-05-23 18:29:12 +02:00
Tobias Brunner
9c42126297 x509: Fix leak when parsing CDPs if an invalid one follows valid ones 2017-05-23 18:29:12 +02:00
Tobias Brunner
b72718f4b8 pem: Ensure a value before checking Proc-Type in PEM header 2017-05-23 18:29:12 +02:00
Tobias Brunner
aed77b0961 chunk: Correctly parse Base64 text where four = follow in a row
That's not correct Base64 but invalid data could trigger this. Since
outlen would get reduced four times, but is only ever increased three
times per iteration, this could result in an integer underflow and then
a potential buffer overflow.
2017-05-23 18:29:12 +02:00
Tobias Brunner
f5aef3a020 configure: Don't modify CFLAGs if fuzzing is enabled
Just rely on the flags passed by the build process.
2017-05-23 18:29:12 +02:00
Tobias Brunner
3963dbbde5 plugin-loader: Disable some logging output when building fuzz targets
This avoids evaluating %N. An alternative would be to define a printf-hook
for plugin features.
2017-05-23 18:29:12 +02:00
Tobias Brunner
92a10e4645 x509: Manually print CRL/OCSP URIs when fuzzing
This avoids a warning about the custom %Y printf specifier.
2017-05-23 18:29:12 +02:00
Tobias Brunner
83eacc448c processor: Move priority threads assignment to set_threads()
This avoids the evaluation of %N even if the thread pool is never used.
We need to avoid as many custom printf specifiers as possible when
fuzzing our code to avoid excessive log messages.
2017-05-23 18:29:12 +02:00
Tobias Brunner
05eeffb2f2 fuzz: Change how fuzz_certs is built
We mainly do this because we have to create a self-contained executable
and it isn't so easy to actually get libtool to link e.g. libgmp
statically.
2017-05-23 18:29:12 +02:00
Tobias Brunner
4a0b6d659d Add plugin constructor registration for all libraries that provide plugins
Unfortunately, we can't just add the generated C file to the sources in
Makefile.am as the linker would remove that object file when it notices
that no symbol in it is ever referenced.  So we include it in the file
that contains the library initialization, which will definitely be
referenced by the executable.

This allows building an almost stand-alone static version of e.g. charon
when building with `--enable-monolithic --enable-static --disable-shared`
(without `--disable-shared` libtool will only build a version that links
the libraries dynamically).  External libraries (e.g. gmp or openssl) are
not linked statically this way, though.
2017-05-23 18:29:12 +02:00
Tobias Brunner
8699275ed6 plugin-constructors: Add script to generate constructor registration
Using a Python script so this works in cross-compilation situations.
2017-05-23 18:29:12 +02:00
Tobias Brunner
1a06bf03f9 plugin-loader: Add facility to register plugin constructors
Enabled when building monolithically and statically.

This should allow us to work around the -whole-archive issue with
libtool.  If the libraries register the plugin constructors they provide
they reference the constructors and will therefore prevent the linker from
removing these seemingly unused symbols from the final executable.

For use cases where dlsym() can be used, e.g. because the static libraries
are manually linked with -whole-archive (Linux) or -force-load (Apple),
this can be disabled by passing ss_cv_static_plugin_constructors=no to
the configure script.
2017-05-23 18:29:12 +02:00
Tobias Brunner
6ce649a8a6 configure: Don't build static libraries by default
This way we can actually detect if someone wants to build strongSwan
statically because --enable-static has to be passed explicitly.
2017-05-23 18:29:11 +02:00
Tobias Brunner
98b55c8b83 library: Add compile option to disable memwipe() check 2017-05-23 18:29:11 +02:00
Tobias Brunner
8806b00f43 fuzz: Make path to libFuzzer.a configurable 2017-05-23 18:29:11 +02:00
Tobias Brunner
30c03a7df9 pem: Don't read beyond line ends 2017-05-23 18:29:11 +02:00
Tobias Brunner
388351609d x509: Fix leak if there is an empty CDP 2017-05-23 18:29:11 +02:00
Tobias Brunner
5e37f7e550 x509: Fix leak if a certificate contains multiple authorityKeyIdentifiers 2017-05-23 18:29:11 +02:00
Tobias Brunner
157742be7d fuzz: Add fuzzing boilerplate 2017-05-23 18:29:11 +02:00
Tobias Brunner
4d0795bcef testing: Avoid expiration of allocated SPIs due to low retransmission settings 2017-05-23 18:05:58 +02:00
Tobias Brunner
70855696ad kernel-netlink: Use total retransmit timeout as acquire timeout
By using the total retransmit timeout, modifications of timeout settings
automatically reflect on the value of xfrm_acq_expires.  If set, the
value of xfrm_acq_expires configured by the user takes precedence over
the calculated value.
2017-05-23 18:05:58 +02:00
Tobias Brunner
bfbd3af850 task-manager: Add helper function to calculate the total retransmit timeout 2017-05-23 18:05:58 +02:00
Tobias Brunner
389e4b8e67 ike: Use optional jitter to calculate retransmission timeouts
Also adds an optional limit to avoid very high retransmission timeouts
with high numbers of retries.
2017-05-23 18:02:15 +02:00
Thomas Egerer
d140b3bd3f kernel-netlink: Try to add new inbound SA if update fails
When establishing a traffic-triggered CHILD_SA involves the setup of an
IKE_SA more than one exchange is required. As a result the temporary
acquire state may have expired -- even if the acquire expiration
(xfrm_acq_expires) time is set properly (165 by default).  The expire
message sent by the kernel is not processed in charon since no trap can
be found by the trap manager.
A possible solution could be to track allocated SPIs.  But since this is
a corner case and the tracking introduces quite a bit of overhead, it
seems much more sensible to add a new state if the update of a state
fails with NOT_FOUND.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2017-05-23 17:58:51 +02:00
Tobias Brunner
bf08e39441 kernel-pfkey: Update SA addresses if supported by the kernel
Upcoming FreeBSD kernels will support updating the addresses of existing
SAs with new SADB_X_EXT_NEW_ADDRESS_SRC|DST extensions for the SADB_UPDATE
message.
2017-05-23 17:58:50 +02:00
Tobias Brunner
a080cfece0 kernel-pfkey: Use new encap flag on Mac OS X when updating SAs 2017-05-23 17:58:50 +02:00
Thomas Egerer
3a67df3b10 receiver: Restrict init limit to half-open SAs as responder
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2017-05-23 17:53:20 +02:00
Tobias Brunner
6b9361f714 Merge branch 'hw-offload'
Allows enabling hardware offload for IPsec SAs as introduced by Linux 4.11
for specific hardware.
2017-05-23 17:00:04 +02:00
Tobias Brunner
48ea655016 kernel-netlink: Update hardware offload attribute when SAs are updated 2017-05-23 16:58:06 +02:00
Tobias Brunner
0b5dfaeb5c kernel-netlink: Base SA update on correct message in multi-message response 2017-05-23 16:58:06 +02:00
Tobias Brunner
7c4f88d4be vici: Make hardware offload configurable 2017-05-23 16:58:00 +02:00
Tobias Brunner
aeee0bcc30 child-sa: Optionally enable hardware offload for CHILD_SAs 2017-05-23 16:55:21 +02:00
Tobias Brunner
4a17583051 child-cfg: Add flag to enable hardware offload 2017-05-23 16:54:36 +02:00
Tobias Brunner
749ac175fa child-cfg: Use flags for boolean options
Makes it potentially easier to add new flags.
2017-05-23 16:51:15 +02:00
Tobias Brunner
d42948fc05 kernel-netlink: Enable hardware offloading if configured for an SA 2017-05-23 16:51:03 +02:00
Tobias Brunner
35a53d6491 kernel-ipsec: Add flag to enable hardware offloading for an IPsec SA 2017-05-23 16:51:03 +02:00
Tobias Brunner
5bfae68670 include: Update xfrm.h to include hardware offloading extensions 2017-05-23 16:51:02 +02:00
Tobias Brunner
7caec9e4a4 kernel-netlink: Directly handle Netlink messages if thread pool is empty
During initialization of the plugins the thread pool is not yet
initialized so there is no watcher thread that could handle the queued
Netlink message and the main thread will wait indefinitely for a
response.

Fixes #2199.
2017-05-23 16:49:39 +02:00
Martin Willi
9b29003cd9 socket-default: Add an option to force the sending interface via IP_PKTINFO
On Linux, setting the source address is insufficient to force a packet to be
sent over a certain path. The kernel uses the best route to select the outgoing
interface, even if we set a source address of a lower priority interface. This
is not only true for interfaces attaching to the same subnet, but also for
unrelated interfaces; the kernel (at least on 4.7) sends out the packet on
whatever interface it sees fit, even if that network does not expect packets
from the source address we force to.

When a better interface becomes available, strongSwan sends its MOBIKE address
list update using the old source address. But the kernel sends that packet over
the new best interface. If that network drops packets having the unexpected
source address from the old path, the MOBIKE update fails and the SA finally
times out.

To enforce a specific interface for our packet, we explicitly set the interface
index from the interface where the source address is installed. According to
ip(7), this overrules the specified source address to the primary interface
address. As this could have side effects to installations using multiple
addresses on a single interface, we disable the option by default for now.

This also allows using IPv6 link-local addresses, which won't work if
the outbound interface is not set explicitly.
2017-05-23 16:49:39 +02:00
Tobias Brunner
46a3f92a76 Add an option to announce support for IKE fragmentation but not sending fragments 2017-05-23 16:41:57 +02:00
Tobias Brunner
cbbd34f507 swanctl: Use returned key ID to track loaded private keys
There was a direct call to load_key() for unencrypted keys that didn't
remove the key ID from the hashtable, which caused keys to get unloaded
when --load-creds was called multiple times.
2017-05-23 16:41:02 +02:00
Tobias Brunner
605a98c7ce vici: Return key ID from load-key command
We already do this for load-token and this should simplify client
implementations.
2017-05-23 16:41:02 +02:00
Adrian-Ken Rueegsegger
6a8a44be88 credential-manager: Prefer local over global sets
Invert set enumeration order to first enumerate local and then global
credential sets.
2017-05-23 16:36:35 +02:00