18418 Commits

Author SHA1 Message Date
Tobias Brunner
6ab9297b5d android: Move package namespace declaration from Manifest to build file 2022-09-21 13:54:37 +02:00
Tobias Brunner
a09727465c android: Remove unused jni directory spec from sourceSets 2022-09-21 13:54:37 +02:00
Tobias Brunner
cd698bf46b android: Update Gradle plugin 2022-09-21 13:54:37 +02:00
Tobias Brunner
357d680649 socket-win: Don't set SO_REUSEADDR on IKE sockets anymore
Same as the change for socket-default in a previous commit.
2022-09-21 13:53:44 +02:00
Tobias Brunner
5f9ad62a81 socket-dynamic: Don't set SO_REUSEADDR on IKE sockets anymore
Same as the previous commit.
2022-09-21 13:53:44 +02:00
Tobias Brunner
83da133712 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.
2022-09-21 13:53:44 +02:00
Tobias Brunner
0da8cae671 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
2022-09-21 13:53:44 +02:00
Tobias Brunner
cdeb724839 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.
2022-09-21 13:53:44 +02:00
Tobias Brunner
9efd7d7e90 eap: Print vendor (PEN) names for vendor-specific EAP methods 2022-09-21 13:53:44 +02:00
Tobias Brunner
f6e6fcd2f6 eap: Use pen_t instead of uint32_t for vendor ID 2022-09-21 13:53:44 +02:00
Andreas Steffen
8f5ff23d6c Version bump to 5.9.8dr4 5.9.8dr4 2022-09-20 16:37:44 +02:00
Andreas Steffen
063ef084e4 pki: Base64 encoding of username:password in HTTP basic authentication 2022-09-20 11:07:33 +02:00
Martin Willi
a708e96906 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.
2022-09-20 11:07:33 +02:00
Tobias Brunner
75d820de8b 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.
2022-09-20 10:50:36 +02:00
Tobias Brunner
231df029b0 pki: Add SCEP utility functions and enums to Doxygen doc 2022-09-20 10:18:36 +02:00
Tobias Brunner
f21ef43b0c 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
2022-09-20 10:15:13 +02:00
Tobias Brunner
33f5e23c4e 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
2022-09-20 10:09:59 +02:00
Tobias Brunner
2740c50bb8 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.
2022-09-20 10:06:14 +02:00
Tobias Brunner
6f456afe39 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.
2022-09-20 10:04:06 +02:00
Tobias Brunner
69995ed2c4 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
2022-09-20 10:03:02 +02:00
Tobias Brunner
48e9267d7a 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
2022-09-20 09:53:13 +02:00
Tobias Brunner
724b1a8ae8 kernel-pfkey: Increase debug level of the "querying ..." log messages
References strongswan/strongswan#1271
2022-09-16 16:46:45 +02:00
Noel Kuntze
cf16556248 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
2022-09-16 16:40:06 +02:00
Tobias Brunner
88c80df6f4 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.
2022-09-16 15:28:16 +02:00
Tobias Brunner
d29af802bb 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
2022-09-16 15:26:43 +02:00
Tobias Brunner
8a57c2ab52 configure: Add an option to build with AddressSanitizer 2022-09-15 18:23:57 +02:00
Tobias Brunner
c4563abc2e github: Use OpenSSL 3.0.5 for tests 2022-09-15 12:16:12 +02:00
Tobias Brunner
a7e8cb8f61 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.
2022-09-15 12:16:12 +02:00
Tobias Brunner
eab9cd8661 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]
2022-09-15 12:16:12 +02:00
Tobias Brunner
ae9d110dd9 configure: Log if -Werror is enabled 2022-09-15 12:16:12 +02:00
Tobias Brunner
c9c8911478 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.
2022-09-15 12:16:12 +02:00
Thomas Egerer
996f557c40 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>
2022-09-15 12:16:12 +02:00
Tobias Brunner
bdc7f84a23 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.
2022-09-15 12:16:12 +02:00
Tobias Brunner
80b2c6cdc5 gcrypt: Return correct IV length (0) for ECB mode 2022-09-15 12:16:12 +02:00
Tobias Brunner
7217ff5fc5 aesni: Fix out-of-bound read when loading 192-bit AES keys 2022-09-15 12:16:12 +02:00
Tobias Brunner
f2456376ae 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")
2022-09-15 12:16:12 +02:00
Tobias Brunner
5eeeb894d1 test-runner: Clean up collected run times 2022-09-15 12:16:12 +02:00
Martin Willi
b18fbde41e test-runner: Properly clean up allocated test suites 2022-09-15 12:16:12 +02:00
Martin Willi
432a846e66 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.
2022-09-15 12:16:12 +02:00
Martin Willi
7dce58135e 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.
2022-09-15 12:16:12 +02:00
Martin Willi
d840df185a utils: Define ADDRESS_SANITIZER_EXCLUDE to exclude a function from sanitizer 2022-09-15 12:16:12 +02:00
Martin Willi
1866d33538 utils: Support __has_feature() macro on non-LLVM compilers by returning 0 2022-09-15 12:16:12 +02:00
Tobias Brunner
ffada7cb5a pki: Correctly use int as precision specifier when printing PEM certificate 2022-09-14 17:38:59 +02:00
Tobias Brunner
644f74ad8f unit-tests: Add environment variable to only run specific iterations
Helpful when running with increased verbosity and only specific iterations
fail.
2022-09-12 16:13:51 +02:00
Andreas Steffen
a345e635c4 Version bumpt to 5.9.8dr3 5.9.8dr3 2022-09-07 06:38:42 +02:00
Andreas Steffen
747e840912 libstrongswan: Encode RSA-PSS algorithmIdentifier variant
Some third party IKEv2 products expect an RSA-PSS ASN.1
algorithmIdentifier with an explicit trailerField value (CONTEXT3)
instead of the DEFAULT value if the trailerField is missing.

The setting charon.rsa_pss_trailerfield = yes enables the explicit
encoding.
2022-09-06 21:15:43 +02:00
Andreas Steffen
bf3f678551 testing: Fixed two issues 2022-09-06 21:14:07 +02:00
Tobias Brunner
f4931ce7e6 testing: Add missing kernel config for 5.19
The config went missing when 057b3806aad4 ("Version bump to 5.9.8dr1")
changed the default kernel version.
2022-09-06 16:56:31 +02:00
Tobias Brunner
55f7268eb1 unit-tests: Let the TLS server thread close its own socket
Closing the socket from the main thread, while the server thread is
still in accept() (or is just about to enter it), seems to
occasionally cause a deadlock on macOS.
2022-09-06 15:40:32 +02:00
Boi Sletterink
c6b6ad8d89 testing: Add missing css dir to distribution tarballs
Add the css dir to the EXTRA_DIST variable in the Makefile for the test
environment. This dir was missing when generating distribution tarballs.
Adding it enables successful builds of the test environment from the
dist tarballs.

Fixes: 63f35993d9fb ("testing: Use sans-serif font for test results")
Closes strongswan/strongswan#1266
2022-09-06 09:49:45 +02:00