]> git.ipfire.org Git - thirdparty/strongswan.git/log
thirdparty/strongswan.git
2 years agogithub: Adapt to switch to Ubuntu 22.04 for ubuntu-latest
Tobias Brunner [Mon, 28 Nov 2022 16:01:45 +0000 (17:01 +0100)] 
github: Adapt to switch to Ubuntu 22.04 for ubuntu-latest

Ubuntu 22.04 ships OpenSSL 3, which requires debug symbols so we can
whitelist leaks because we don't deinitialize the library.  And because
the shipped library is not built with `-fno-omit-frame-pointer`, the
build with AddressSanitizer can't use its fast stack unwind method.
However, the previous workaround for DTLS handling with glibc apparently
isn't necessary anymore.

In the custom OpenSSL build we drop no-stdio as that lets the configure
check for libldns fail because ERR_print_errors_fp@OPENSSL_3.0.0 is not
found.

For ccache, the default path to the cache directory has changed.

Also simplified the NM tests as there is only one build since
085daf474330 ("nm: Remove old libnm-glib compat stuff").

2 years agogithub: Set timeout for tests on macOS
Tobias Brunner [Thu, 1 Dec 2022 12:33:01 +0000 (13:33 +0100)] 
github: Set timeout for tests on macOS

They sometimes hang (without our internal timeout catching them).
So instead of waiting for hours, let them get aborted earlier.

2 years agofuzz: Force `make check` to fail if fuzz target fails
Tobias Brunner [Thu, 1 Dec 2022 15:31:23 +0000 (16:31 +0100)] 
fuzz: Force `make check` to fail if fuzz target fails

2 years agoleak-detective: Whitelist additional OpenSSL 3 functions
Tobias Brunner [Thu, 1 Dec 2022 08:40:21 +0000 (09:40 +0100)] 
leak-detective: Whitelist additional OpenSSL 3 functions

These are necessary when building against the OpenSSL 3 version shipped
with Ubuntu (the first is only seen when built with --enable-bfd-backtraces).

2 years agobacktrace: Suppress internal errors by libbfd
Tobias Brunner [Thu, 1 Dec 2022 08:31:44 +0000 (09:31 +0100)] 
backtrace: Suppress internal errors by libbfd

At least since Ubuntu 22.04 there are lots of (apparently non-fatal)
"DWARF error: could not find variable specification" errors generated
by bfd_find_nearest_line().  This also happens with addr2line, which
internally uses libbfd.  No idea what the actual issue is (it still
happens with binutils 2.39 in Ubuntu 22.10), but since it doesn't seem
to affect the functionality we need this avoids filling the test logs
with useless messages.

2 years agobacktrace: Add ability to lookup function names via libbfd
Tobias Brunner [Thu, 1 Dec 2022 08:29:17 +0000 (09:29 +0100)] 
backtrace: Add ability to lookup function names via libbfd

dladdr() is not always able to determine the function names while
libbfd often can in such cases.

2 years agoaf-alg: Fix compiler warning
Tobias Brunner [Thu, 1 Dec 2022 08:27:44 +0000 (09:27 +0100)] 
af-alg: Fix compiler warning

2 years agofarp: Remove unused variable
Tobias Brunner [Tue, 29 Nov 2022 16:56:40 +0000 (17:56 +0100)] 
farp: Remove unused variable

2 years agonm: Ignore lock file left behind by newer versions of intltool
Tobias Brunner [Tue, 29 Nov 2022 16:55:37 +0000 (17:55 +0100)] 
nm: Ignore lock file left behind by newer versions of intltool

2 years agothread: Exclude thread_main() from AddressSanitizer
Tobias Brunner [Tue, 29 Nov 2022 15:51:06 +0000 (16:51 +0100)] 
thread: Exclude thread_main() from AddressSanitizer

With GCC 11.3 AddressSanitizer causes the following crash when a thread
is cancelled (e.g. in the test_condvar_cancel test):

==84365==AddressSanitizer CHECK failed: ../../../../src/libsanitizer/asan/asan_thread.cpp:367 "((ptr[0] == kCurrentStackFrameMagic)) != (0)" (0x0, 0x0)
    #0 0x7ff0801b2988 in AsanCheckFailed ../../../../src/libsanitizer/asan/asan_rtl.cpp:74
    #1 0x7ff0801d330e in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) ../../../../src/libsanitizer/sanitizer_common/sanitizer_termination.cpp:78
    #2 0x7ff0801b810c in __asan::AsanThread::GetStackFrameAccessByAddr(unsigned long, __asan::AsanThread::StackFrameAccess*) ../../../../src/libsanitizer/asan/asan_thread.cpp:367
    #3 0x7ff080122e9b in __asan::GetStackAddressInformation(unsigned long, unsigned long, __asan::StackAddressDescription*) ../../../../src/libsanitizer/asan/asan_descriptions.cpp:203
    #4 0x7ff0801242d8 in __asan::AddressDescription::AddressDescription(unsigned long, unsigned long, bool) ../../../../src/libsanitizer/asan/asan_descriptions.cpp:455
    #5 0x7ff0801242d8 in __asan::AddressDescription::AddressDescription(unsigned long, unsigned long, bool) ../../../../src/libsanitizer/asan/asan_descriptions.cpp:439
    #6 0x7ff080126a84 in __asan::ErrorGeneric::ErrorGeneric(unsigned int, unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long) ../../../../src/libsanitizer/asan/asan_errors.cpp:389
    #7 0x7ff0801b1fa5 in __asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool) ../../../../src/libsanitizer/asan/asan_report.cpp:476
    #8 0x7ff080148fe8 in __interceptor_sigaltstack ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:9986
    #9 0x7ff0801af473 in __asan::PlatformUnpoisonStacks() ../../../../src/libsanitizer/asan/asan_posix.cpp:44
    #10 0x7ff0801b500c in __asan_handle_no_return ../../../../src/libsanitizer/asan/asan_rtl.cpp:612
    #11 0x7ff07fe04d50 in thread_main /media/sf_scratch/src/libstrongswan/threading/thread.c:321
    #12 0x7ff07d7d4b42 in start_thread nptl/pthread_create.c:442
    #13 0x7ff07d8669ff  (/lib/x86_64-linux-gnu/libc.so.6+0x1269ff)

2 years agotnccs: Fix Doxygen comments for callback
Tobias Brunner [Mon, 28 Nov 2022 16:15:13 +0000 (17:15 +0100)] 
tnccs: Fix Doxygen comments for callback

2 years agocallback-cred: Document missing callback argument
Tobias Brunner [Mon, 28 Nov 2022 16:13:11 +0000 (17:13 +0100)] 
callback-cred: Document missing callback argument

2 years agoDoxyfile: Remove obsolete options and replace obsolete paper type value
Tobias Brunner [Mon, 28 Nov 2022 16:11:25 +0000 (17:11 +0100)] 
Doxyfile: Remove obsolete options and replace obsolete paper type value

2 years agoUse Botan 2.19.3 for tests
Tobias Brunner [Mon, 28 Nov 2022 15:02:25 +0000 (16:02 +0100)] 
Use Botan 2.19.3 for tests

2 years agotesting: Use HTTPS for strongSwan tarballs
Tobias Brunner [Mon, 28 Nov 2022 14:57:57 +0000 (15:57 +0100)] 
testing: Use HTTPS for strongSwan tarballs

2 years agotesting: Fix URL for kernel patches
Tobias Brunner [Mon, 28 Nov 2022 14:55:31 +0000 (15:55 +0100)] 
testing: Fix URL for kernel patches

2 years agoMerge branch 'number-formats'
Tobias Brunner [Thu, 10 Nov 2022 15:53:50 +0000 (16:53 +0100)] 
Merge branch 'number-formats'

Document the accepted number formats in swanctl.conf/strongswan.conf and
clarify some details for specific options.

Closes strongswan/strongswan#1329

2 years agoswanctl: Document the type/size of interface IDs
Tobias Brunner [Fri, 14 Oct 2022 09:04:38 +0000 (11:04 +0200)] 
swanctl: Document the type/size of interface IDs

2 years agoswanctl: Document the behavior of %unique[-dir] on IKE_SAs
Tobias Brunner [Fri, 14 Oct 2022 08:57:53 +0000 (10:57 +0200)] 
swanctl: Document the behavior of %unique[-dir] on IKE_SAs

2 years agoconf: Document accepted number and time formats
Tobias Brunner [Fri, 14 Oct 2022 08:54:04 +0000 (10:54 +0200)] 
conf: Document accepted number and time formats

2 years agoconf: Explicitly add time unit to default value for options that accept them
Tobias Brunner [Fri, 14 Oct 2022 08:53:26 +0000 (10:53 +0200)] 
conf: Explicitly add time unit to default value for options that accept them

2 years agowolfssl: Updates to resolve build conflicts
Tim Weller [Tue, 4 Oct 2022 16:44:09 +0000 (11:44 -0500)] 
wolfssl: Updates to resolve build conflicts

The wolfSSL's OpenSSL compatibility layer is not used by the plugin at
all and preventing its inclusion avoids conflicts with ASN1_ constants.

The inclusion of wolfssl/ssl.h is moved to the only file that requires
it as older wolfSSL versions defined a conflicting ASN1_GENERALIZEDTIME.

Other changes address issues with the FIPS use case.

Closes strongswan/strongswan#1332

2 years agoUse wolfSSL 5.5.3 for tests
Tobias Brunner [Wed, 9 Nov 2022 16:36:42 +0000 (17:36 +0100)] 
Use wolfSSL 5.5.3 for tests

2 years agogithub: Use OpenSSL 3.0.7 for tests
Tobias Brunner [Wed, 9 Nov 2022 16:39:50 +0000 (17:39 +0100)] 
github: Use OpenSSL 3.0.7 for tests

2 years agobacktrace: Fix build with newer MinGW versions
Tobias Brunner [Thu, 10 Nov 2022 12:44:21 +0000 (13:44 +0100)] 
backtrace: Fix build with newer MinGW versions

A recent change added CALLBACK to PENUM_PAGE_FILE_CALLBACKW/A in psapi.h,
which conflicts with our own macro of the same name.  Our compat/windows.h
header undefs the Windows definition, but that only works if Windows
headers are included before ours, which wasn't the case for psapi.h.

2 years agogithub: Fix URL to BoringSSL repository for Android build
Tobias Brunner [Sat, 5 Nov 2022 13:58:02 +0000 (14:58 +0100)] 
github: Fix URL to BoringSSL repository for Android build

2 years agocirrus: Don't explicitly install openldap*-client on FreeBSD
Tobias Brunner [Thu, 6 Oct 2022 10:06:36 +0000 (12:06 +0200)] 
cirrus: Don't explicitly install openldap*-client on FreeBSD

This avoids a conflicts as mysql80-client has a dependency on either
openldap24-client (FreeBSD 12) or openldap26-client (FreeBSD 13) so e.g.
installing openldap24-client on FreeBSD 13 causes

  openldap26-client-2.6.3 conflicts with openldap24-client-2.4.59_4 on /usr/local/bin/ldapadd

Similarly, when installing openldap26-client on FreeBSD 12.  So just let
the mysql80-client package decide which version is installed.

2 years agogithub: Try to avoid crashes by LeakSanitizer
Tobias Brunner [Thu, 6 Oct 2022 08:22:49 +0000 (10:22 +0200)] 
github: Try to avoid crashes by LeakSanitizer

There are spurious crashes after test runs (during the reporting phase
of LeakSanitizer) that are triggered by seemingly unrelated code changes.
It seems to be related to how glibc handles dynamic TLS allocations.

2 years agoMake functions static that are only accessed from the same compilation unit
Tobias Brunner [Wed, 5 Oct 2022 14:37:22 +0000 (16:37 +0200)] 
Make functions static that are only accessed from the same compilation unit

Also removed some declarations for undefined functions.

2 years agoopenssl: Remove unused openssl_hash_chunk() helper
Tobias Brunner [Wed, 5 Oct 2022 16:14:12 +0000 (18:14 +0200)] 
openssl: Remove unused openssl_hash_chunk() helper

Was used by the ECDSA implementation before 293a912c7de6 ("openssl: Fixes
for ECDSA with OpenSSL 3.0").

2 years agokernel-interface: Make first reqid configurable
Thomas Egerer [Tue, 26 Jul 2022 13:38:34 +0000 (15:38 +0200)] 
kernel-interface: Make first reqid configurable

This can be helpful to reserve low reqids for manual configuration.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2 years agobacktrace: Only define print_sourceline() and esc() if actually used
Tobias Brunner [Mon, 3 Oct 2022 12:06:35 +0000 (14:06 +0200)] 
backtrace: Only define print_sourceline() and esc() if actually used

2 years agolookip: Explicitly include string.h for strcpy()
Tobias Brunner [Mon, 3 Oct 2022 11:54:03 +0000 (13:54 +0200)] 
lookip: Explicitly include string.h for strcpy()

2 years agoerror-notify: Explicitly include string.h for strcpy()
Tobias Brunner [Mon, 3 Oct 2022 11:53:27 +0000 (13:53 +0200)] 
error-notify: Explicitly include string.h for strcpy()

2 years agoVersion bump to 5.9.8 5.9.8
Andreas Steffen [Mon, 3 Oct 2022 14:16:53 +0000 (16:16 +0200)] 
Version bump to 5.9.8

2 years agoNEWS: Add info about CVE-2022-40617
Tobias Brunner [Wed, 21 Sep 2022 08:32:59 +0000 (10:32 +0200)] 
NEWS: Add info about CVE-2022-40617

2 years agocert-validator: Use a separate method for online revocation checking
Tobias Brunner [Wed, 21 Sep 2022 08:22:16 +0000 (10:22 +0200)] 
cert-validator: Use a separate method for online revocation checking

This avoids having to repeat offline checks after basic trust chain
validation.

2 years agorevocation: Enforce a (configurable) timeout when fetching OCSP/CRL
Tobias Brunner [Fri, 22 Jul 2022 12:50:41 +0000 (14:50 +0200)] 
revocation: Enforce a (configurable) timeout when fetching OCSP/CRL

Malicious servers could otherwise block the fetching thread indefinitely
after the initial TCP handshake (which has a default timeout of 10s
in the curl and winhttp plugins, the soup plugin actually has a default
overall timeout of 10s).

2 years agocredential-manager: Do online revocation checks only after basic trust chain validation
Tobias Brunner [Fri, 22 Jul 2022 13:37:43 +0000 (15:37 +0200)] 
credential-manager: Do online revocation checks only after basic trust chain validation

This avoids querying URLs of potentially untrusted certificates, e.g. if
an attacker sends a specially crafted end-entity and intermediate CA
certificate with a CDP that points to a server that completes the
TCP handshake but then does not send any further data, which will block
the fetcher thread (depending on the plugin) for as long as the default
timeout for TCP.  Doing that multiple times will block all worker threads,
leading to a DoS attack.

The logging during the certificate verification obviously changes.  The
following example shows the output of `pki --verify` for the current
strongswan.org certificate:

new:

  using certificate "CN=www.strongswan.org"
  using trusted intermediate ca certificate "C=US, O=Let's Encrypt, CN=R3"
  using trusted ca certificate "C=US, O=Internet Security Research Group, CN=ISRG Root X1"
  reached self-signed root ca with a path length of 1
checking certificate status of "CN=www.strongswan.org"
  requesting ocsp status from 'http://r3.o.lencr.org' ...
  ocsp response correctly signed by "C=US, O=Let's Encrypt, CN=R3"
  ocsp response is valid: until Jul 27 12:59:58 2022
certificate status is good
checking certificate status of "C=US, O=Let's Encrypt, CN=R3"
ocsp response verification failed, no signer certificate 'C=US, O=Let's Encrypt, CN=R3' found
  fetching crl from 'http://x1.c.lencr.org/' ...
  using trusted certificate "C=US, O=Internet Security Research Group, CN=ISRG Root X1"
  crl correctly signed by "C=US, O=Internet Security Research Group, CN=ISRG Root X1"
  crl is valid: until Apr 18 01:59:59 2023
certificate status is good
certificate trusted, lifetimes valid, certificate not revoked

old:

  using certificate "CN=www.strongswan.org"
  using trusted intermediate ca certificate "C=US, O=Let's Encrypt, CN=R3"
checking certificate status of "CN=www.strongswan.org"
  requesting ocsp status from 'http://r3.o.lencr.org' ...
  ocsp response correctly signed by "C=US, O=Let's Encrypt, CN=R3"
  ocsp response is valid: until Jul 27 12:59:58 2022
certificate status is good
  using trusted ca certificate "C=US, O=Internet Security Research Group, CN=ISRG Root X1"
checking certificate status of "C=US, O=Let's Encrypt, CN=R3"
ocsp response verification failed, no signer certificate 'C=US, O=Let's Encrypt, CN=R3' found
  fetching crl from 'http://x1.c.lencr.org/' ...
  using trusted certificate "C=US, O=Internet Security Research Group, CN=ISRG Root X1"
  crl correctly signed by "C=US, O=Internet Security Research Group, CN=ISRG Root X1"
  crl is valid: until Apr 18 01:59:59 2023
certificate status is good
  reached self-signed root ca with a path length of 1
certificate trusted, lifetimes valid, certificate not revoked

Note that this also fixes an issue with the previous dual-use of the
`trusted` flag.  It not only indicated whether the chain is trusted but
also whether the current issuer is the root anchor (the corresponding
flag in the `cert_validator_t` interface is called `anchor`).  This was
a problem when building multi-level trust chains for pre-trusted
end-entity certificates (i.e. where `trusted` is TRUE from the start).
This caused the main loop to get aborted after the first intermediate CA
certificate and the mentioned `anchor` flag wasn't correct in any calls
to `cert_validator_t` implementations.

Fixes: CVE-2022-40617
2 years agopkcs7: Support rsa-pss signatures
Andreas Steffen [Sun, 2 Oct 2022 11:01:34 +0000 (13:01 +0200)] 
pkcs7: Support rsa-pss signatures

2 years agoobject: Make INIT() a compound statement
Tobias Brunner [Thu, 29 Sep 2022 09:36:00 +0000 (11:36 +0200)] 
object: Make INIT() a compound statement

This forces the use of a semicolon after INIT() and makes existing ones,
which was the case for basically all instances, necessary so e.g.
sonarcloud won't complain about an empty statement after every one of
them.

By evaluating to the allocated object, it would theoretically also allow
constructs like this:

  struct_t *this;

  return INIT(this,
   .a = x,
   .b = y,
  );

or this:

  array_insert(a, ARRAY_TAIL, INIT(this,
    .a = x,
    .b = y,
  ));

2 years agopki: Remove superfluous ; when initializing EST client
Tobias Brunner [Thu, 29 Sep 2022 09:34:50 +0000 (11:34 +0200)] 
pki: Remove superfluous ; when initializing EST client

2 years agoNEWS: Add news for 5.9.8
Tobias Brunner [Thu, 29 Sep 2022 07:44:32 +0000 (09:44 +0200)] 
NEWS: Add news for 5.9.8

Also fixed the RFC number for EST.

2 years agogithub: Prefer third-party crypto lib's implementations over ours
Tobias Brunner [Wed, 28 Sep 2022 15:17:56 +0000 (17:17 +0200)] 
github: Prefer third-party crypto lib's implementations over ours

If e.g. the hmac plugin is loaded before the third-party crypto lib
plugin, we might not use the latter's HMAC implementation in some
cases (e.g. in the libtls tests).

2 years agolgtm: Don't build with ASan and extra warnings
Tobias Brunner [Wed, 28 Sep 2022 13:35:50 +0000 (15:35 +0200)] 
lgtm: Don't build with ASan and extra warnings

2 years agopki: Fix formatting and use `else if` to make Coverity happy
Tobias Brunner [Wed, 28 Sep 2022 13:07:37 +0000 (15:07 +0200)] 
pki: Fix formatting and use `else if` to make Coverity happy

2 years agoUse wolfSSL 5.5.1 for tests
Tobias Brunner [Wed, 28 Sep 2022 12:55:39 +0000 (14:55 +0200)] 
Use wolfSSL 5.5.1 for tests

2 years agoFixed some typos, courtesy of codespell
Tobias Brunner [Tue, 27 Sep 2022 15:14:58 +0000 (17:14 +0200)] 
Fixed some typos, courtesy of codespell

2 years agoVersion bump to 5.9.8rc1 5.9.8rc1
Andreas Steffen [Mon, 26 Sep 2022 08:34:04 +0000 (10:34 +0200)] 
Version bump to 5.9.8rc1

2 years agoikev2: Trigger ike_updown() event after all IKE-specific tasks ran
Tobias Brunner [Thu, 22 Sep 2022 14:14:44 +0000 (16:14 +0200)] 
ikev2: Trigger ike_updown() event after all IKE-specific tasks ran

This makes sure the event is only triggered after the IKE_SA is fully
established and e.g. virtual IPs, additional peer addresses or
a modified reauth time (on the initiator) are assigned to it.  This was
e.g. a problem for the selinux plugin if virtual IPs are used.

We use a separate task to trigger the event that's queued before the
child-create task so the event is triggered before the child_updown()
event.  Same goes for the state change to IKE_ESTABLISHED.

A new condition is used to indicate the successful completion of all
authentication rounds, so we don't have to set the IKE_ESTABLISHED state
in the ike-auth task (it was used as condition in other tasks).

Since set_state() also sets the rekey and reauth times, this required
some minor changes in regards to how AUTH_LIFETIME notifies are handled.

2 years agoikev2: Make sure the child-create task runs after all IKE_SA specific tasks
Tobias Brunner [Thu, 22 Sep 2022 14:04:52 +0000 (16:04 +0200)] 
ikev2: Make sure the child-create task runs after all IKE_SA specific tasks

2 years agoikev2: The ike-me task does not have to run before the ike-auth task
Tobias Brunner [Thu, 22 Sep 2022 13:47:34 +0000 (15:47 +0200)] 
ikev2: The ike-me task does not have to run before the ike-auth task

Since e334bd46b184 ("ike-auth: Move packet collection to post_build()
method") tasks and plugins can modify the IKE_SA_INIT message independent
of the ike-auth task.

2 years agosocket-dynamic: Use IPv6-only mode for IPv6 sockets
Tobias Brunner [Thu, 22 Sep 2022 15:36:38 +0000 (17:36 +0200)] 
socket-dynamic: Use IPv6-only mode for IPv6 sockets

Same as the previous commit.

Fixes: 5f9ad62a8156 ("socket-dynamic: Don't set SO_REUSEADDR on IKE sockets anymore")
2 years agosocket-default: Use IPv6-only mode for IPv6 sockets
Tobias Brunner [Thu, 22 Sep 2022 15:33:52 +0000 (17:33 +0200)] 
socket-default: Use IPv6-only mode for IPv6 sockets

Otherwise, we can't open a dedicated IPv4 socket on the same port as the
IPv6 socket already is set up do receive IPv4 packets (unless we'd again
enable SO_REUSEADDR).

Fixes: 83da13371292 ("socket-default: Don't set SO_REUSEADDR on IKE sockets anymore")
2 years agoandroid: Prevent FD leak from HttpURLConnection
Tobias Brunner [Fri, 22 Jul 2022 09:43:56 +0000 (11:43 +0200)] 
android: Prevent FD leak from HttpURLConnection

The default is apparently "Connection: keep-alive", which somehow keeps
the socket around, which leaks file descriptors with every connection
that fetches OCSP and/or CRLs.  Over time that could result in the number
of FDs reaching a limit e.g. imposed by FD_SET().

Closes strongswan/strongswan#1160

2 years agoandroid: Update dependencies
Tobias Brunner [Fri, 22 Jul 2022 08:26:07 +0000 (10:26 +0200)] 
android: Update dependencies

2 years agoandroid: Set compile-/targetSdkVersion to 32
Tobias Brunner [Fri, 22 Jul 2022 09:13:36 +0000 (11:13 +0200)] 
android: Set compile-/targetSdkVersion to 32

2 years agoandroid: Fix "Format string ... is not valid format string..." error
Tobias Brunner [Fri, 22 Jul 2022 12:10:45 +0000 (14:10 +0200)] 
android: Fix "Format string ... is not valid format string..." error

The linter complained that two of the strings don't actually contain any
printf-specifiers (i.e. don't expect any arguments) and therefore
shouldn't be used with String.format().

2 years agoandroid: Mark PendingIntents as immutable via FLAG_IMMUTABLE
Tobias Brunner [Fri, 22 Jul 2022 09:12:52 +0000 (11:12 +0200)] 
android: Mark PendingIntents as immutable via FLAG_IMMUTABLE

Setting this or explicitly FLAG_MUTABLE is required when targeting
Android 12.

References strongswan/strongswan#1151

2 years agoandroid: Explicitly mark Activities/Services with intent-filter as exported
Tobias Brunner [Fri, 22 Jul 2022 09:11:14 +0000 (11:11 +0200)] 
android: Explicitly mark Activities/Services with intent-filter as exported

Required when targeting Android 12.

2 years agoandroid: Move package namespace declaration from Manifest to build file
Tobias Brunner [Fri, 22 Jul 2022 08:22:05 +0000 (10:22 +0200)] 
android: Move package namespace declaration from Manifest to build file

2 years agoandroid: Remove unused jni directory spec from sourceSets
Tobias Brunner [Fri, 22 Jul 2022 08:20:16 +0000 (10:20 +0200)] 
android: Remove unused jni directory spec from sourceSets

2 years agoandroid: Update Gradle plugin
Tobias Brunner [Fri, 22 Jul 2022 08:20:04 +0000 (10:20 +0200)] 
android: Update Gradle plugin

2 years agosocket-win: Don't set SO_REUSEADDR on IKE sockets anymore
Tobias Brunner [Tue, 6 Sep 2022 14:21:46 +0000 (16:21 +0200)] 
socket-win: Don't set SO_REUSEADDR on IKE sockets anymore

Same as the change for socket-default in a previous commit.

2 years agosocket-dynamic: Don't set SO_REUSEADDR on IKE sockets anymore
Tobias Brunner [Tue, 6 Sep 2022 14:21:03 +0000 (16:21 +0200)] 
socket-dynamic: Don't set SO_REUSEADDR on IKE sockets anymore

Same as the previous commit.

2 years agosocket-default: Don't set SO_REUSEADDR on IKE sockets anymore
Tobias Brunner [Tue, 6 Sep 2022 14:11:49 +0000 (16:11 +0200)] 
socket-default: Don't set SO_REUSEADDR on IKE sockets anymore

This was originally required when pluto and charon both bound sockets to
the same port to send messages.  Pluto also received messages on them but
charon didn't and used a raw socket instead.  Since the removal of pluto
we don't need to set this option anymore, which might actually mask
mistakes like running charon and charon-systemd concurrently (that could
result in messages getting sent fine by both daemons but only received
by one).

Note that a failure to create/bind the sockets will not immediately
result in a shutdown of the daemon.  Instead, there will be an error
once the receiver tries to read any messages and also whenever the sender
attempts to send a request.

2 years agoMerge branch 'eap-vendor-id'
Tobias Brunner [Wed, 21 Sep 2022 11:37:18 +0000 (13:37 +0200)] 
Merge branch 'eap-vendor-id'

Changes the type for EAP vendor IDs from uint32_t to pen_t, which has
explicitly been added to represent three-byte IANA-allocated Private
Enterprise Numbers (PEN), which the EAP RFC called "SMI Network
Management Private Enterprise Codes".

References strongswan/strongswan#581

2 years agoeap: Make sure eap_type_t is large enough to hold vendor-specific types
Tobias Brunner [Thu, 21 Jul 2022 11:37:01 +0000 (13:37 +0200)] 
eap: Make sure eap_type_t is large enough to hold vendor-specific types

Unless compiled with `-fshort-enumes` that's usually the case already.

2 years agoeap: Print vendor (PEN) names for vendor-specific EAP methods
Tobias Brunner [Thu, 21 Jul 2022 11:19:56 +0000 (13:19 +0200)] 
eap: Print vendor (PEN) names for vendor-specific EAP methods

2 years agoeap: Use pen_t instead of uint32_t for vendor ID
Tobias Brunner [Thu, 21 Jul 2022 11:06:56 +0000 (13:06 +0200)] 
eap: Use pen_t instead of uint32_t for vendor ID

2 years agoVersion bump to 5.9.8dr4 5.9.8dr4
Andreas Steffen [Tue, 20 Sep 2022 14:37:44 +0000 (16:37 +0200)] 
Version bump to 5.9.8dr4

2 years agopki: Base64 encoding of username:password in HTTP basic authentication
Andreas Steffen [Tue, 20 Sep 2022 06:49:40 +0000 (08:49 +0200)] 
pki: Base64 encoding of username:password in HTTP basic authentication

2 years agopki: Always and implicitly use base64 encoding for EST requests/response
Martin Willi [Tue, 20 Sep 2022 05:47:25 +0000 (07:47 +0200)] 
pki: Always and implicitly use base64 encoding for EST requests/response

Content-Transfer-Encoding is actually not a valid HTTP header, but a MIME
header, and must not be used. The original RFC7030 specifies this wrong,
and an errata discusses this issue.

The use of base64 encoding has been clarified in RFC8951, and the
recommendation is to always use/expect base64 encoding, but not send/expect
the Content-Transfer-Encoding header.

2 years agoscepclient: Remove documentation about removal of scepclient
Tobias Brunner [Wed, 14 Sep 2022 15:54:23 +0000 (17:54 +0200)] 
scepclient: Remove documentation about removal of scepclient

There should be no need for such a persistent documentation on a removed
component in the repository.  The commit history is enough.  And besides
that, there is user-facing documentation about it in the docs and the
changelog/NEWS.

2 years agopki: Add SCEP utility functions and enums to Doxygen doc
Tobias Brunner [Wed, 14 Sep 2022 15:53:36 +0000 (17:53 +0200)] 
pki: Add SCEP utility functions and enums to Doxygen doc

2 years agovici: Ignore NULL message in raise_event()
Tobias Brunner [Tue, 6 Sep 2022 14:32:47 +0000 (16:32 +0200)] 
vici: Ignore NULL message in raise_event()

There are a lot of calls like this:

  this->dispatcher->raise_event(this->dispatcher, "...", 0,
                                b->finalize(b));

However, if finalize() fails, e.g. because a previous call to add()
failed due to the size limit, it returns NULL.  This then caused a
segmentation fault in raise_event() when it interacted with that value.

Closes strongswan/strongswan#1278

2 years agoMerge branch 'ike-sa-flush'
Tobias Brunner [Tue, 20 Sep 2022 08:09:59 +0000 (10:09 +0200)] 
Merge branch 'ike-sa-flush'

This fixes a race condition during shutdown between the main thread
flushing the IKE_SA manager and worker threads still creating IKE_SAs.

Closes strongswan/strongswan#1252

2 years agoike-sa-manager: Make sure flush() removes entries that might get added concurrently
Tobias Brunner [Fri, 26 Aug 2022 14:14:30 +0000 (16:14 +0200)] 
ike-sa-manager: Make sure flush() removes entries that might get added concurrently

Because flush() has to release the segment locks intermittently, threads
might add new entries (even with the change in the previous commit as the
IKE_SA might already be created, just not registered/checked in yet).

Since those entries are added to the front of the segment lists, the
enumerator in the previous step 2 didn't notice them and did not wait
for them to get checked in.  However, step 3 and 4 then proceeded to
delete and destroy the entry and IKE_SA, which could lead to a crash
once the other thread attempts to check in the already destroyed IKE_SA.

This change combines the three loops of steps 2-4 but then loops over
the whole table until it's actually empty.  This way we wait for and
destroy newly added entries.

2 years agoike-sa-manager: Prevent new IKE_SA from getting created when flush() is called
Tobias Brunner [Fri, 26 Aug 2022 13:33:22 +0000 (15:33 +0200)] 
ike-sa-manager: Prevent new IKE_SA from getting created when flush() is called

Without ability to create SPIs, other threads are prevented from creating
new IKE_SAs while we are flushing existing IKE_SAs.  However, there could
still be IKE_SAs already created that might get checked in while the
segments are temporarily unlocked to wait for threads to check existing
SAs in.

2 years agoike-sa: Always set ike_cfg_t when setting peer_cfg_t
Tobias Brunner [Fri, 26 Aug 2022 15:29:00 +0000 (17:29 +0200)] 
ike-sa: Always set ike_cfg_t when setting peer_cfg_t

This is more consistent and e.g. allows to properly take into account
some settings that are also relevant during IKE_AUTH (e.g. childless).

We also already use the peer_cfg_t's ike_cfg_t when rekeying,
reauthenticating and reestablishing an IKE_SA (and e.g. for DSCP).

Also changed are some IKEv1 cases where get_ike_cfg() is called before
set_peer_cfg() without taking a reference to the ike_cfg_t that might
get replaced/destroyed (none of the cases were problematic, though, but
it also wasn't necessary to keep the ike_cfg_t around).

Closes strongswan/strongswan#1238

2 years agocred-encoding: Avoid potential use after free when caching encodings
Tobias Brunner [Thu, 18 Aug 2022 10:04:39 +0000 (12:04 +0200)] 
cred-encoding: Avoid potential use after free when caching encodings

The pattern currently is to call get_cache(), generate the encoding
if that failed and then store it with cache().  The latter adopts the
passed encoding and frees any stored encoding.  However, the latter means
that if two threads concurrently fail to get a cached encoding and then
both generate and store one, one of the threads might use an encoding
that was freed by the other thread.

Since encodings are not expected to change, we can avoid this issue by
not replacing an existing cache entry and instead return that (while
freeing the passed value instead of the cached one).

Closes strongswan/strongswan#1231

2 years agokernel-pfkey: Increase debug level of the "querying ..." log messages
Tobias Brunner [Fri, 16 Sep 2022 14:33:42 +0000 (16:33 +0200)] 
kernel-pfkey: Increase debug level of the "querying ..." log messages

References strongswan/strongswan#1271

2 years agokernel-netlink: Increase debug level of the "querying [...]" log messages
Noel Kuntze [Fri, 2 Sep 2022 23:37:33 +0000 (01:37 +0200)] 
kernel-netlink: Increase debug level of the "querying [...]" log messages

When watching the output of `swanctl -l` during debugging, the debug
messages in query_sa/policy() cause a lot of noise in the logs (level 2
for DBG_KNL still has actually useful information that we want to see
in the logs) and they're not very useful.

Compared to the messages in the functions above, the ones in update_sa()
and get_replay_state() are not seen often. But since there already is a
log message on level 2 in update_sa(), they're kinda redundant.

Closes strongswan/strongswan#1271

2 years agoMerge branch 'asan'
Tobias Brunner [Fri, 16 Sep 2022 13:28:16 +0000 (15:28 +0200)] 
Merge branch 'asan'

Enables AddressSanitizer in most CI builds that don't use leak-detective.
For custom builds it can easily be enabled via --enable-asan.

2 years agogithub: Enable AddressSanitizer if leak-detective is disabled
Tobias Brunner [Tue, 13 Sep 2022 15:23:55 +0000 (17:23 +0200)] 
github: Enable AddressSanitizer if leak-detective is disabled

At least for the tests where it is available and works.  It conflicts
with the instrumentation used by the coverage and fuzzing (and possibly
sonarcloud) tests, the toolchain for the Windows builds doesn't seem to
support it, and on FreeBSD the test executables hang due to a
compatibility issue with FreeBSD's qsort(), which has been fixed [1],
but that has not made it into the clang version in the base system.

For the custom OpenSSL build, debug symbols are enabled so we can
suppress some leaks properly.

[1] https://github.com/llvm/llvm-project/issues/46176

2 years agoconfigure: Add an option to build with AddressSanitizer
Tobias Brunner [Thu, 15 Sep 2022 10:05:14 +0000 (12:05 +0200)] 
configure: Add an option to build with AddressSanitizer

2 years agogithub: Use OpenSSL 3.0.5 for tests
Tobias Brunner [Tue, 13 Sep 2022 16:05:01 +0000 (18:05 +0200)] 
github: Use OpenSSL 3.0.5 for tests

2 years agotun-device: Fix compiler warning
Tobias Brunner [Thu, 15 Sep 2022 08:49:42 +0000 (10:49 +0200)] 
tun-device: Fix compiler warning

Only the second was reported by the compiler (depending on the version
and similarly to the previous commit only with AddressSanitizer active).
The strncpy() call for UTUN_CONTROL_NAME was simply wrong.

2 years agokernel-netlink: Fix compiler warnings with strncpy()
Tobias Brunner [Thu, 15 Sep 2022 08:08:10 +0000 (10:08 +0200)] 
kernel-netlink: Fix compiler warnings with strncpy()

Normally, GCC sees that we terminate the destination with a zero byte.
However, when using `-fsanitize=address`, there seems to be additional
instrumentation code after strncpy() so GCC produces warnings like
these:

‘__builtin_strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]

2 years agoconfigure: Log if -Werror is enabled
Tobias Brunner [Tue, 13 Sep 2022 15:25:12 +0000 (17:25 +0200)] 
configure: Log if -Werror is enabled

2 years agounit-tests: Don't link files from libimcv into the test executable
Tobias Brunner [Wed, 14 Sep 2022 14:03:57 +0000 (16:03 +0200)] 
unit-tests: Don't link files from libimcv into the test executable

This causes odr-violation errors with libasan as some symbols will be
defined twice, once in the linked libimcv and once in the test
executable itself.

2 years agounit-tests: Use allocated listener instead of stack object in exchange tests
Thomas Egerer [Fri, 2 Sep 2022 11:54:05 +0000 (11:54 +0000)] 
unit-tests: Use allocated listener instead of stack object in exchange tests

When using the statement expression and a stack object along with
clang-11 and libasan, we get quite a lot of errors about reading
invalid memory. This is due to clang making the actual listener_t local
to the block, such that the access outside of the macros using
_assert_payload is (correctly) considered an error.
By using a heap allocated object, we can destroy it once the listener
returns FALSE (cleaning up properly), and since bus_t does not touch the
listener after that, we don't get any errors from libasan.

Co-authored-by: Tobias Brunner <tobias@strongswan.org>
2 years agounit-tests: Don't use test data on stack for TLS socket tests
Tobias Brunner [Tue, 13 Sep 2022 14:10:55 +0000 (16:10 +0200)] 
unit-tests: Don't use test data on stack for TLS socket tests

The stack of that function might not be valid anymore once data is read.

2 years agogcrypt: Return correct IV length (0) for ECB mode
Tobias Brunner [Tue, 13 Sep 2022 13:26:47 +0000 (15:26 +0200)] 
gcrypt: Return correct IV length (0) for ECB mode

2 years agoaesni: Fix out-of-bound read when loading 192-bit AES keys
Tobias Brunner [Tue, 13 Sep 2022 13:16:47 +0000 (15:16 +0200)] 
aesni: Fix out-of-bound read when loading 192-bit AES keys

2 years agoike-rekey: Correctly destroy colliding rekey task
Tobias Brunner [Tue, 13 Sep 2022 13:03:24 +0000 (15:03 +0200)] 
ike-rekey: Correctly destroy colliding rekey task

Using DESTROY_IF() this way doesn't correctly check if the pointer
is set.

Fixes: 7ffeed01c0d7 ("ike-rekey: Remove collision task type checks")
2 years agotest-runner: Clean up collected run times
Tobias Brunner [Tue, 13 Sep 2022 12:55:30 +0000 (14:55 +0200)] 
test-runner: Clean up collected run times

2 years agotest-runner: Properly clean up allocated test suites
Martin Willi [Wed, 8 Apr 2015 08:20:23 +0000 (10:20 +0200)] 
test-runner: Properly clean up allocated test suites

2 years agounit-tests: Disable AddressSanitizer for threading cleanup function
Martin Willi [Wed, 8 Apr 2015 08:18:31 +0000 (10:18 +0200)] 
unit-tests: Disable AddressSanitizer for threading cleanup function

As the cleanup function reads from the correct address on the parent frame,
it is currently unclear why AddressSanitizer complains about that pointer
dereference.

2 years agounit-tests: Exclude memory checks after-free from AddressSanitizer
Martin Willi [Wed, 8 Apr 2015 08:16:13 +0000 (10:16 +0200)] 
unit-tests: Exclude memory checks after-free from AddressSanitizer

We explicitly test the memory we free()d if that got properly wiped, so suppress
the warning from AddressSanitizer.