19588 Commits

Author SHA1 Message Date
Tobias Brunner
e9ebe49d44 testing: Add option to run tests without leak detective
This new option allows to disable leak detective to reduce the runtime
during development.  Either only for the command line (swanctl, pki etc.)
or optionally also for the daemon(s).

Disabling leak detective only for the CLI tools already brings a
considerable reduction in runtime (from 48m to 38m on my dev host) as
there are many such calls in the post-test stage.  Any leaks in those
tools are also a lot less of an issue than leaks in the daemon.  So using
this during development should be fine as long as a full test run is done
regularly (in particular before releases).  Disabling leak detective
completely further reduces the runtime (to 30m on my dev host). But that
should probably only be used for functional regression tests after
verifying new code didn't introduce new leaks.

This also fixes the service script which is used for charon-tkm since
16fcdb460afd ("charon-tkm: Don't use starter/stroke with charon-tkm anymore").
2025-09-18 11:13:32 +02:00
Tobias Brunner
906205b7ee testing: Use Debian trixie to test TKM 2025-09-18 11:13:32 +02:00
Tobias Brunner
a0a5bd7669 testing: Use Debian trixie 2025-09-18 11:13:32 +02:00
Tobias Brunner
f3cc9bec18 testing: Use proper directory for slapd PID files 2025-09-18 11:13:32 +02:00
Tobias Brunner
d8a1747fa1 libimcv: Add Debian 13 (trixie) to database 2025-09-18 11:13:32 +02:00
Tobias Brunner
3aa7e1d418 testing: Increase memory for guest hosts to run Debian trixie
While some increase was necessary anyway because the idle system requires
about 5-10 MiB more memory, the main issue is resolving the code line and
function name in case of a memory leak.  Calling addr2line requires a lot
more memory than before.  Using backtraces via libbfd doesn't help either
because the trigger is the bfd_find_nearest_line() call we use as well.
And because we'd try to resolve all symbols that way (for whitelisting),
the memory overhead would be even higher and affect every shutdown, even
if no leak occurred.  It also causes a significant time overhead (running
all tests took 75m instead of 48m).

I also tested switching to ASAN/LSAN.  The peak memory usage is slightly
higher than when using libbfd, but enabling it also increased the runtime
overhead a lot (the daemon and swanctl both required about 10-20 MiB more
memory, not just during the shutdown).
2025-09-18 11:13:32 +02:00
Tobias Brunner
1767ba2a13 testing: Add support for Debian trixie base images 2025-09-18 11:13:32 +02:00
Tobias Brunner
518b8e4286 testing: Use pipx to install swidGenerator on Debian trixie
We could use the same approach on bookworm (if the base image is updated),
but just use the old approach there for now.
2025-09-18 11:13:32 +02:00
Tobias Brunner
fa1cd74712 testing: Install required packages in venv of updated strongTNC
Update revision for some dependency updates.  While python3-setuptools is
installed on the system, the venv apparently can't use it.  legacy-cgi is
required to use that old Django version with newer Python releases.
2025-09-18 11:13:32 +02:00
Tobias Brunner
ecc2e35713 testing: Update TKM RPC to be compatible with newer compilers 2025-09-18 11:13:32 +02:00
Tobias Brunner
b4a51f1719 testing: Use newer version of TKM on trixie
The API for libgmpada has change with 1.6 in a way that's not
backwards-compatible.  So we use a different revision that includes
the required changes depending on the Debian version.

This also adds support for esa_select(), to support seamless rekeyings,
which requires updating xfrm-ada as well.
2025-09-18 11:13:32 +02:00
Tobias Brunner
ddeb3c463e testing: Run commands in chroot in a login shell
Similar to the previous commit, this ensures we have the same environment
we do later on the system.
2025-09-18 11:13:32 +02:00
Tobias Brunner
870aa75eed testing: Start a login shell in chroot script
This ensures we have the same environment (e.g. stuff from /etc/profile.d)
as when logging in via SSH later.
2025-09-18 11:13:32 +02:00
Tobias Brunner
b998695344 testing: Ignore unknown memory in leak detective
This is set in two locations for systemd services and login shells. The
memory is freed by OPENSSL_cleanup().
2025-09-18 11:13:32 +02:00
Tobias Brunner
0e768233f2 leak-detective: Include OpenSSL symbol seen on Debian trixie 2025-09-18 11:13:32 +02:00
Tobias Brunner
a9e3db6b79 testing: Pass base image codename to application Makefiles
Some might require it to use different revisions or commands.
2025-09-18 11:13:32 +02:00
Tobias Brunner
b51731e197 testing: Mount /proc in the chroot to make systemctl happy 2025-09-18 11:13:27 +02:00
Tobias Brunner
a418666f59 testing: Use new recommended approach to install key for custom apt repository
apt-key add is deprecated (and not available in trixie) as it makes the
available for all sources.  The recommended approach makes the key very
specifically available for just our repository.
2025-09-18 11:12:22 +02:00
Tobias Brunner
2025f630df testing: Remove unnecessary workaround for DHCP 2025-09-18 11:12:22 +02:00
Tobias Brunner
acaf4b2d17 testing: Move sysctl settings to sysctl.d and add some memory settings
Debian trixie doesn't provide a 99-sysctl.conf symlink in that directory
anymore.  The memory settings are also useful there as the default of
one changed and overbooking helps when forking a process with large
memory footprint (e.g. the IKE daemon).
2025-09-18 11:12:22 +02:00
Tobias Brunner
5e85ce17a2 testing: Remove xconsole config for rsyslogd
This produces a warning and we don't have X.
2025-09-18 11:12:22 +02:00
Tobias Brunner
2eef6b242b github: Use AWS-LC 1.61.1 for tests 2025-09-18 08:29:39 +02:00
Tobias Brunner
ac0272cad1 host: Don't try to resolve %any* keywords with mismatched address family
While host_create_from_string_and_family() usually replaces %any*
keywords, this fails if the address family doesn't match (e.g. %any4 with
AF_INET6).  There is no point in trying to resolve these keywords via
DNS as % is no valid character for host names.

Closes strongswan/strongswan#2880
2025-09-16 10:14:26 +02:00
Tobias Brunner
e33dddffea github: Use latest SonarQube action 2025-09-15 17:46:03 +02:00
Tobias Brunner
45f5a7a698 curl: Fix types enforced by compiler check in newer libcurl headers 2025-09-15 16:51:42 +02:00
Tobias Brunner
cfb5e46a98 Merge branch 'plugin-versions'
This adds a symbol with the current version number to all existing
plugins (the PLUGIN_DEFINE() macro makes this easy).  The version is
checked when a plugin is loaded from a file in order to prevent loading
old plugins from any previous build, which could cause all sorts of
issues.

References strongswan/strongswan#2835
2025-08-22 16:49:31 +02:00
Tobias Brunner
c4b32aab04 plugin-loader: Check version of loaded plugins
This prevents loading plugins from older builds that can cause all sorts
of issues as they might access struct members in different locations.

We don't check the version for statically linked plugins.
2025-08-22 15:32:39 +02:00
Tobias Brunner
5cab5672e7 Define plugin version in all existing plugins 2025-08-22 15:32:39 +02:00
Tobias Brunner
d087c349b4 plugin: Add macro to define plugin version and constructor 2025-08-22 15:32:39 +02:00
Tobias Brunner
1b551a9bfd plugin-loader: Don't prevent dynamic linking in addition to static constructors
When built with static plugins and constructors, we might still want to
be able to load external plugins.

Fixes: d860c26e9533 ("plugin-loader: Properly support compilation without dlopen()/dlsym() etc.")
2025-08-22 15:32:39 +02:00
Tobias Brunner
e9fa338e23 pkcs11: Improve detection of already unwrapped CKA_EC_POINTs
If an uncompressed point is already unwrapped (incorrect but some tokens/
modules do this) and therefore still looks like an ASN.1 octet string,
there could be false positives with the previous checks that lead to
mangled points.

By ensuring that we unwrapped the complete ASN.1 chunk, we can already
reduce the false positive rate when the assumed length is smaller than
the chunk, which we previously accepted but isn't the case in correctly
encoded points.

And while we already checked that the first byte indicates a valid point
type/encoding, there could still be false positives.  We can avoid those
with some checks on the length of the unwrapped point.  In particular,
enforcing a multiple of 4/8 should fail for valid unwrapped points where
three bytes were removed in the process (ASN.1 tag and length, point
encoding).

Closes strongswan/strongswan#2872
2025-08-22 15:31:25 +02:00
Tobias Brunner
abadd47736 charon-cmd: Cache shared secret under identities if available
We won't have identities for private key passwords, but we do for EAP
identities and they might get reused if redirected.
2025-08-22 15:27:00 +02:00
Tobias Brunner
d662a69d9d ike-sa-manager: Avoid deadlock due to race condition during shutdown
If an entry is added while we wait for a checked out SA in flush() (e.g.
due to an action performed by that SA), new entries might get inserted
before the one we wait for.  If that was the first entry in the row, we
didn't correctly update the table and the new entries were basically lost
by overwriting the first entry in the row.  As the SA count was still
increased but the new entries couldn't get enumerated, the daemon wasn't
terminated properly but was stuck in the loop in flush().
2025-08-22 15:26:59 +02:00
Tobias Brunner
3e0123526f trap-manager: Migrate tracked IKE SA in case of redirect during IKE_AUTH 2025-08-22 15:26:59 +02:00
Tobias Brunner
ee668ae91e controller: Migrate tracked IKE SA in case of redirect during IKE_AUTH 2025-08-22 15:26:59 +02:00
Tobias Brunner
3a9120373d ike-sa: Avoid reusing established IKE_SAs that got redirected
These will get terminated by the peer after a while.  So we don't want
to reuse them.
2025-08-22 15:26:59 +02:00
Tobias Brunner
2f0a0fef3d vici: Fix indentation for some add_kv() calls 2025-08-22 15:22:33 +02:00
Mathias Aerts
a24dc2e9ad vici: Include configured local and remote ports in list-conns
Closes strongswan/strongswan#2869
2025-08-22 15:22:13 +02:00
Tobias Brunner
b36da850b5 github: Only run CI for latest commit in a branch, cancel old runs 2025-08-22 12:21:50 +02:00
Tobias Brunner
7b90dc93c0 libipsec: Run unit tests with TESTS_PLUGINS if specified 2025-08-22 12:11:11 +02:00
Tobias Brunner
9da68ec9f5 libtls: Fix double-free when enumerating private keys 2025-08-22 12:07:55 +02:00
Tobias Brunner
dcb53e076b testing: Disable deprecated features in Botan
We keep MD5 enabled for now as we need it for TLS 1.0/1.1.  Once we
remove that we can reconsider (although, it's also needed for EAP-MD5
and since MD4 is disabled as well, which means EAP-MSCHAPv2 won't
be available, we'd be left with only EAP-GTC for simple username/password
authentication, which nobody else supports).
2025-08-22 12:07:55 +02:00
Tobias Brunner
8139256aae botan: Replace calls to deprecated botan_privkey|pubkey_export() 2025-08-22 11:52:51 +02:00
Tobias Brunner
5e4ff88849 github: Use OpenSSL 3.5.2 for tests 2025-08-21 16:44:01 +02:00
Tobias Brunner
d973106eed github: Use AWS-LC 1.58.1 for tests 2025-08-21 16:44:01 +02:00
Tobias Brunner
052a939553 openssl: Add support for Ed25519 via AWS-LC 2025-08-21 16:44:01 +02:00
Tobias Brunner
4096a911a0 github: Check active transforms against reference files
Also collect current results so we can update reference files easily.

Enabled AES-CFB in wolfSSL as we have already support for it in the
plugin.
2025-08-21 16:16:01 +02:00
Tobias Brunner
545eb2416a unit-tests: Add option to collect active crypto transforms
This will allow us to compare new library versions against previous ones,
so we don't suddenly loose some algorithms like it happened with KDFs
recently after updating OpenSSL to 3.5.1.
2025-08-21 16:16:01 +02:00
Tobias Brunner
4c85b9d21b credential-factory: Avoid deadlock during unit tests
If a unit test times out while generating a private key (e.g. because of
a lack of entropy), this avoids a deadlock by still releasing the read
lock that'd prevent acquiring the write lock when plugins are unloaded.

Closes strongswan/strongswan#2850
2025-08-21 16:13:24 +02:00
Tobias Brunner
135ed6aada openssl: Simplify wrapping private key objects 2025-08-21 16:11:13 +02:00