]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
6 months agoallow user to specify 'local' multiple times in config files
Antonio Quartulli [Thu, 23 Jan 2025 15:51:11 +0000 (16:51 +0100)] 
allow user to specify 'local' multiple times in config files

It is now possible to specify 'local' multiple times in a server
config to let it listen on multiple sockets (address:port) of
the same protocol.

Change-Id: I4d1c96662c5a8c750d883e3b20adde09529e2764
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250123155111.23371-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30544.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agoIPv6 MADDR LOG: Wrap IPv6 addresses in square brackets and print port when the port...
Marco Baffo [Fri, 17 Jan 2025 11:04:22 +0000 (12:04 +0100)] 
IPv6 MADDR LOG: Wrap IPv6 addresses in square brackets and print port when the port is specified

  Updated the mroute_addr_print_ex() function to wrap IPv6 addresses in square
  brackets and printing the port when the port is specified, e.g., [2001:db8::1]:8080 .
  When the port is not specified the IPv6 address formatting remain the same, e.g., 2001:db8::1 .

Change-Id: Ia58cff107d14e29e51df0a988e8337cbb70ebfbb
Signed-off-by: Marco Baffo <marco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250117110422.921-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30480.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agoFix some trivial sign-compare compiler warnings
Frank Lichtenheld [Tue, 14 Jan 2025 16:52:06 +0000 (17:52 +0100)] 
Fix some trivial sign-compare compiler warnings

Change-Id: I1918c43202b87f0c987bfd9155c739da7dd02632
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250114165206.13187-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30455.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agossl_openssl: Clean up unused functions and add missing "static"
Frank Lichtenheld [Tue, 14 Jan 2025 16:49:38 +0000 (17:49 +0100)] 
ssl_openssl: Clean up unused functions and add missing "static"

Just some misc cleanups found while looking at the code.

Change-Id: Ifa06a3cb843dbf6a9639164d12aabe572aab162c
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250114164938.12828-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30453.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agoconsole_systemd: remove the timeout when using 'systemd-ask-password'
Ben Boeckel [Tue, 31 Dec 2024 20:46:29 +0000 (21:46 +0100)] 
console_systemd: remove the timeout when using 'systemd-ask-password'

Without this, the password request will expire after 90 seconds leaving
no way to provide the password without OpenVPN asking for it again.
Given that interactive use will wait for input without a timeout, it
makes sense to have non-interactive usage also wait until the user is
ready instead of forcing users to race against the timeout.

Change-Id: I2791d09ab698d89dc7e0183151f77b84024ad6d1
Signed-off-by: Ben Boeckel <ben.boeckel@kitware.com>
Acked-By: David Sommerseth <davids@openvpn.net>
Message-Id: <20241231204629.1210040-2-ben.boeckel@kitware.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30336.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agoImprove peer fingerprint documentation
Arne Schwabe [Tue, 14 Jan 2025 13:49:09 +0000 (14:49 +0100)] 
Improve peer fingerprint documentation

- fix typo in peer-fingerprint
- use ec_paramgen_curve instead of requiring a subshell

Note: we still use -nodes instead of -noenc as it is more compatible.

Github: closes OpenVPN/openvpn#666

Change-Id: I9a12a0c127908af9f09d88fb3a493df3763d0cc5
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250114134909.31334-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30447.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agoFix 'uninitialized pointer read' in openvpn_decrypt_aead
Frank Lichtenheld [Mon, 13 Jan 2025 11:22:26 +0000 (12:22 +0100)] 
Fix 'uninitialized pointer read' in openvpn_decrypt_aead

Coverity complains that if we error out in the first
error condition we try to free gc without initializing
it.

While here move the declaration of outlen to the first
usage.

Change-Id: I0391f30a1e962ee242e9bcdec4f605bf7e831cca
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20250113112226.17728-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30421.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agoRename aead-tag-at-end to aead-epoch
Arne Schwabe [Thu, 9 Jan 2025 21:28:03 +0000 (22:28 +0100)] 
Rename aead-tag-at-end to aead-epoch

Since we introduce aead at the end and epoch data keys together
and only allow the aead tag at the end if epoch data keys are
used, we can use just one flag for both of them

Change-Id: I9e9433b56dcbaa538d9bed30e50cf74948c647cc
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: MaxF <max@max-fillinger.net>
Message-Id: <20250109212803.11505-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30395.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agoImplement methods to generate and manage OpenVPN Epoch keys
Arne Schwabe [Thu, 9 Jan 2025 18:05:37 +0000 (19:05 +0100)] 
Implement methods to generate and manage OpenVPN Epoch keys

This implements functions that allow these keys to be generated and
managed. It does not yet implement using them for the data channel.

Change-Id: Id7d6a576ca8c9560cb2dfae82fc62175820e9b80
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: MaxF <max@max-fillinger.net>
Message-Id: <20250109180537.27686-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30390.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agoAdd methods to read/write packet ids for epoch data
Arne Schwabe [Thu, 9 Jan 2025 17:55:28 +0000 (18:55 +0100)] 
Add methods to read/write packet ids for epoch data

Change-Id: I2a104decdb1e77a460f7a6976bcd0560b67a07b5
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: MaxF <max@max-fillinger.net>
Message-Id: <20250109175528.22033-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30389.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agoDo not attempt to decrypt packets anymore after 2**36 failed decryptions
Arne Schwabe [Thu, 9 Jan 2025 17:49:28 +0000 (18:49 +0100)] 
Do not attempt to decrypt packets anymore after 2**36 failed decryptions

To avoid attacks (especially on Chacha20-Poly1305) we do not allow
decryption anymore after 2**36 failed verifications.

After 2**35, we trigger a renegotiation (to avoid that situation).

For the theoretical background, see

   - https://datatracker.ietf.org/doc/draft-irtf-cfrg-aead-limits/
   - RFC 9147 (DTLS 1.3) section 4.5.3 "AEAD limits"
   - https://eprint.iacr.org/2024/051.pdf

Change-Id: I81440ac28a1ad553652e201234e5ddfe03a8c190
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: MaxF <max@max-fillinger.net>
Message-Id: <20250109174928.17862-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30387.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agoAllow DEFAULT in data-ciphers and report both expanded and user set option
Arne Schwabe [Fri, 27 Dec 2024 12:46:32 +0000 (13:46 +0100)] 
Allow DEFAULT in data-ciphers and report both expanded and user set option

This adds support for parsing DEFAULT in data-ciphers, the idea is that people
can modify the default without repeating the default ciphers.

In the past we have seem that people will use data-ciphers BF-CBC or
data-ciphers AES-128-CBC when getting the warning that the cipher is not
supported by the server.  This commit aims to provide a better way for
these situation as we still want people to rely on default cipher selection
from OpenVPN when possible.

Change-Id: Ia1c5209022d3ab4c0dac6438c41891c7d059f812
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20241227124632.110920-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30245.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agodco-win: simplify do_close_link_socket()
Lev Stipakov [Tue, 31 Dec 2024 14:54:17 +0000 (15:54 +0100)] 
dco-win: simplify do_close_link_socket()

c->c2.link_socket_owned is true in client mode
and for the global context in the server mode -
those are exactly the cases when we want to
set sd to undefined when using dco-win.

Change-Id: I3232dd8d855ca3f198b4ca3b2ef4f67cec49f3d4
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241231145417.12128-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30328.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agodco-win: enable mode server on supported configuration
Lev Stipakov [Mon, 30 Dec 2024 19:32:04 +0000 (20:32 +0100)] 
dco-win: enable mode server on supported configuration

Enable dco-win with mode server if driver supports it.

Disable for proto TCP or older drivers.

Change-Id: Iea4538cee075d50de836d1ef7652985186b2527c
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241230193204.9897-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30317.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoAdapt socket handling to support listening on multiple sockets
Antonio Quartulli [Mon, 30 Dec 2024 16:23:37 +0000 (17:23 +0100)] 
Adapt socket handling to support listening on multiple sockets

    Introduce internal changes preparing the server to
    handle multiple sockets concurrently for both
    TCP and UDP protocols. While no user-visible
    features are implemented yet, these modifications
    are essential for enabling future functionality
    such as listening on multiple ports.

    Key changes are: converting link_socket from a
    single pointer to an array in various contexts,
    in order to be able to store multiple sockets
    at once.

Change-Id: Ia0a889e800f0b36aed770ee36e31afeec5df6084
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241230162338.21401-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30309.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agodco-win: factor out getting dco version
Lev Stipakov [Sun, 29 Dec 2024 14:17:59 +0000 (15:17 +0100)] 
dco-win: factor out getting dco version

As a preparation for multipeer and data_v3,
add function which returns dco version in
machine-readable format.

Change-Id: I8e8ddd35bd3cc3334faf7f57118d1892512ae9f7
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241229141800.4734-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30297.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoImprove shuffling algorithm of connection list
Shuji Furukawa [Mon, 18 Nov 2024 14:20:20 +0000 (23:20 +0900)] 
Improve shuffling algorithm of connection list

This patch implements the Fisher-Yates shuffle algorithm to ensure that all
permutations of the connection target list are generated with equal
probability, eliminating biases present in the previous shuffling method. In
the Fisher-Yates algorithm, there's only one way to obtain each permutation
through a series of element swaps, so all permutations occur with equal
probability in theory.

Signed-off-by: Shuji Furukawa <shujifurukawa1213@gmail.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20241118142019.31045-1-shujifurukawa1213@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29837.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoRegenerate doxygen config file with doxygen -u
Frank Lichtenheld [Fri, 27 Dec 2024 18:22:42 +0000 (19:22 +0100)] 
Regenerate doxygen config file with doxygen -u

We clearly do not maintain this file, so let's
doxygen do it. Drops some obsolte parameters but
otherwise shouldn't change anything.

Change-Id: Ia6fa1fd8161126bd8e7fba00f28c55dc29bb0cef
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20241227182242.8664-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30278.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agooverride ai_family if 'local' numeric address was specified
Antonio Quartulli [Fri, 27 Dec 2024 16:17:55 +0000 (17:17 +0100)] 
override ai_family if 'local' numeric address was specified

This change ensures that when a numeric IP address is specified
as argument to a 'local' directive, its ai_family overrides
the one extracted from the 'proto' config option.

Change-Id: Ie2471e6b2d6974e70423b09918ad1c2136253754
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241227161755.4010-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30257.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoReview doxygen warnings
Frank Lichtenheld [Fri, 27 Dec 2024 16:16:48 +0000 (17:16 +0100)] 
Review doxygen warnings

We write doxygen comments but we do not verify them. So
quite some errors have crept in. Trying to reduce them
by reviewing the warnings output of doxygen and addressing
most of them.

Did generally ignore "The following parameter is not documented"
warnings (except those caused by typos). Fixing those will
require more work.

Usual errors fixed:
 - Wrong usage of @file
 - Wrong spellings of @param
 - Desync between function declaration and comment
   (usually param names)

Change-Id: I7a852eb5fafae3a0e85dd89ea6d4c91fcf2fab4e
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20241227161648.3350-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30256.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoChange API of init_key_ctx to use struct key_parameters
Arne Schwabe [Fri, 27 Dec 2024 11:11:33 +0000 (12:11 +0100)] 
Change API of init_key_ctx to use struct key_parameters

This introduces a new structure key_parameters. The reason is that the
current struct serves both as an internal struct as well as an
on-wire/in-file format. Separate these two different usages to allow
extending the struct.

Change-Id: I4a981c5a70717e2276d89bf83a06c7fdbe6712d7
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20241227111133.5893-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30228.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoGHA: General update December 2024
Frank Lichtenheld [Fri, 27 Dec 2024 14:36:52 +0000 (15:36 +0100)] 
GHA: General update December 2024

Contains the following renovate updates:

- Update dependency libressl/portable to v4
  - Requires setting LIBRESSL_GIT_OPTIONS
    since the default is --depth=8 which is
    unusable for checking out tags.
- Update dependency Mbed-TLS/mbedtls to v3.6.2
- Update mingw ubuntu runner to v24
  - Do NOT update the uncrustify runner since newer uncrustify
    is not usable with the current config
- Update vcpkg digest to 80d54ff
- Update github actions

Additionally change the action reference pinning
to consistently refer to the tags instead of the branches.

Change-Id: I91f68317450c3c0d69be2c489276739211ccb422
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Yuriy Darnobyt <yura.uddr@gmail.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20241227143652.147284-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30251.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoEnsure that Python3 is available
Arne Schwabe [Fri, 27 Dec 2024 11:22:55 +0000 (12:22 +0100)] 
Ensure that Python3 is available

Use the more standard cmake find_package to search for Python3 and make it required. This also provides
a better error message than "version.cmake" not found when python3 is missing.

Change-Id: I350fd615ed8474d34392a057a5f8bded78173949
Signed-off-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20241227112255.11992-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30232.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoAdd building/testing with msbuild and the clang compiler
Arne Schwabe [Fri, 27 Dec 2024 11:22:07 +0000 (12:22 +0100)] 
Add building/testing with msbuild and the clang compiler

The LLVM/clang compiler warning and error message are easier too read
than their MSVC cl counterparts. Also compiling/running tests on Windows
with a different compiler has the benefit of a better coverage.

This includes a few minor changes to allow clang-cl to compile the
project.

Change-Id: I43d84034f3e920a45731c4aab4f851a60921290d
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20241227112209.11572-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30231.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoAdd small unit test for buf_chomp
Arne Schwabe [Wed, 25 Dec 2024 16:56:29 +0000 (17:56 +0100)] 
Add small unit test for buf_chomp

Change-Id: Ia0799189d45223e0b987a5a4da5be60404388f1f
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241225165629.5558-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30206.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoSupport IPv6 towards port-share proxy receiver
Corubba Smith [Sat, 14 Dec 2024 19:56:56 +0000 (20:56 +0100)] 
Support IPv6 towards port-share proxy receiver

While port-share already supports IPv6 connections from clients, it only
supported IPv4 connections towards the proxy receiver. The used
common/shared OpenVPN machinery is already IPv6-ready, so all needed was
to use properly-sized `sockaddr` structs and removing hardcoded IPv4
restrictions.

Signed-off-by: Corubba Smith <corubba@gmx.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <dcc7e538-2035-4697-b306-10eb470632f3@gmx.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30115.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoChange internal id of packet id to uint64
Arne Schwabe [Wed, 25 Dec 2024 14:21:31 +0000 (15:21 +0100)] 
Change internal id of packet id to uint64

This allows to get rid of multiple casts and also prepares for the
larger packet id used by epoch data format.

Change-Id: If470af2eb456b2b10f9f2806933e026842188c42
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241225142131.12543-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30199.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agorepair DNS address option
Lev Stipakov [Tue, 24 Dec 2024 17:42:33 +0000 (18:42 +0100)] 
repair DNS address option

Commit

  6f2d222 ("dns: store IPv4 addresses in network byte order")

changed the internal representation of IPv4 address within DNS
settings to network byte order, however later this value is copied into
tuntap_options, where IPv4 addresses are assumed to be in host byte
order (see lots of occurences of "htonl(tt->" in tun.c). As a
consequence, DNS server address is set incorrectly, like 4.4.8.8 instead
of 8.8.4.4

Fix by converting address to host byte order when copying from DNS
options to tuntap_options.

Change-Id: I87e4593e6a548bacd40b840cd241950019fa457d
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241224174233.13005-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30195.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoMove initialisation of implicit IVs to init_key_ctx_bi methods
Arne Schwabe [Sun, 22 Dec 2024 21:45:41 +0000 (22:45 +0100)] 
Move initialisation of implicit IVs to init_key_ctx_bi methods

This is really more a function of initialising the data cipher and key
context and putting it into the init_key_ctx_bi makes more sense.

It will allow calling init_key_ctx_bi to fully initialise a
data channel key without calling some extra functions after that
which will make the (upcoming) epoch key implementation cleaner.

Also ensure that free_ctx_bi actually also sets initialized to false.

Change-Id: Id223612c7bcab91d49c013fb775024bd64ab0836
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241222214541.11021-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30170.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoSplit init_key_ctx_bi into send/recv init
Arne Schwabe [Sat, 21 Dec 2024 22:39:05 +0000 (23:39 +0100)] 
Split init_key_ctx_bi into send/recv init

This allows for only initialising one of the keys. This is needed
for epoch keys where key rotation of send/recv key can happen at
different time points.

Change-Id: If9e029bdac264dcc05b2d256c4d323315904a92b
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241221223905.18820-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30151.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoservice: add utf8to16 function that takes a size
Heiko Hund [Sat, 21 Dec 2024 22:41:36 +0000 (23:41 +0100)] 
service: add utf8to16 function that takes a size

utf8to16_size() takes the size of the to be converted string. This is
needed to convert MULTI_SZ strings, which contain inline NUL characters,
but can be useful in other cases as well.

Change-Id: I6b4aa3d63c0b684bf95841271c04bc5d9c37793b
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241221224136.20984-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30158.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoImplement HKDF expand function based on RFC 8446
Arne Schwabe [Sat, 21 Dec 2024 22:24:04 +0000 (23:24 +0100)] 
Implement HKDF expand function based on RFC 8446

Use crypto_epoch.c/h for the new functions since they are
linked to the epoch key usage in OpenVPN.

Change-Id: I3a1c6561f4d9a69e2a441d49dff620b4258a1bcc
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: MaxF <max@max-fillinger.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241221222404.10266-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30149.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoTrigger renegotiation of data key if getting close to the AEAD usage limit
Arne Schwabe [Sat, 21 Dec 2024 15:37:30 +0000 (16:37 +0100)] 
Trigger renegotiation of data key if getting close to the AEAD usage limit

This implements the limitation of AEAD key usage[1] with a confidentiality
margin of 2^-57, the same as TLS 1.3.  In this implementation, unlike
TLS 1.3 that counts the number of records, we count the actual number of
packets and plaintext blocks. TLS 1.3 can reasonable assume that for
large data transfers, full records are used and therefore the maximum
record size of 2**14 (2*10 blocks) is used to calculate the number of
records before a new key needs to be used.

For a VPN like OpenVPN, the same calculation would either require using a
pessimistic assumption of using a MTU size of 65k which limits us to
2^24 packets, which equals only 24 GB with more common MTU/MSS of 1400
or requiring a dynamic calculation which includes the actual MTU that
we allow to send. For 1500 the calculation yields 2*29.4 which is a
quite significant higher number of packets (923 GB at 1400 MSS/MTU).

To avoid this dynamic calculation and also avoid needing to know the
MSS/MTU size in the crypto layer, this implementation foregoes the
simplification of counting just packets but will count blocks and packets
instead and determines the limit from that.

This also has the side effect that connections with a lot of small packets
(like TCP ACKs) mixed with large packets will be able to keep using the same
key much longer until requiring a renegotiation.

This patch will set the limit where to trigger the renegotiation at 7/8
of the recommended maximum value.

[1]  https://www.ietf.org/archive/id/draft-irtf-cfrg-aead-limits-08.html

Testing instructions:

The easiest way to test if this patch works as
intended is to manually change the return value of cipher_get_aead_limits
to some silly low value like 2048. After a bit of VPN traffic, a soft
reset should occur that indicates being over the

    TLS: soft reset sec=41/3600 bytes=59720/-1 pkts=78/0 aead_limit_send=1883/1792 aead_limit_recv=1937/1792

Here the send limit is over the limit (1792 = 2048 * 8/7).

Change-Id: I057f007577f10c6ac917ee4620ee3d2559187dc7
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241221153731.1755-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30144.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agodns: clone options via pointer instead of copy
Heiko Hund [Fri, 13 Dec 2024 16:46:30 +0000 (17:46 +0100)] 
dns: clone options via pointer instead of copy

Change-Id: I12b8bb26c0cb70e50b2d42b1c69018894e9f080c
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20241213164630.266045-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30112.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agodns: store IPv4 addresses in network byte order
Heiko Hund [Fri, 13 Dec 2024 16:45:52 +0000 (17:45 +0100)] 
dns: store IPv4 addresses in network byte order

This is done so that inet_ntop(3) can be used with IPv4 name server
addresses. It expects the binary address in network byte order. If they
are not that way the address octets are reversed.

Change-Id: I81d4bb0abdd421f5ba260c10c610918652334a4d
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20241213164552.265863-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30111.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoUse XOR instead of concatenation for calculation of IV from implicit IV
Arne Schwabe [Thu, 12 Dec 2024 14:38:45 +0000 (15:38 +0100)] 
Use XOR instead of concatenation for calculation of IV from implicit IV

This change prepares the extended packet id data where also the packet id
part of the IV will be derived using xor.  Using xor also in the AEAD
case where this degenerates to a concatenation allows using the same
IV generation code later.

Change-Id: I74216d776d3e0a8dc987ec7b1671c8e8dcccdbd6
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: MaxF <max@max-fillinger.net>
Acked-by: Antonio Quartulli <antonio@mandelbit.com>
Acked-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241212143845.4090-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30097.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoforward: Fix potential unaligned access in drop_if_recursive_routing
Frank Lichtenheld [Wed, 11 Dec 2024 17:13:48 +0000 (18:13 +0100)] 
forward: Fix potential unaligned access in drop_if_recursive_routing

ASAN error:
   forward.c:1433:13: runtime error: member access within misaligned
   address 0x51e00002f52e for type 'const struct in6_addr', which
   requires 4 byte alignment

replace IN6_ARE_ADDR_EQUAL() which uses 32bit compares on Linux - alignment
sensitive - with our own OPENVPN_IN6_ARE_ADDR_EQUAL() macro, which always
does memcpy() and does not care for alignment.

v2: Use memcmp instead of memcpy

Change-Id: I74a9eec4954f3f9d208792b6b34357571f76ae4c
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241211171349.8892-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30074.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoFix memory leak in ntlm_support
Frank Lichtenheld [Mon, 9 Dec 2024 19:49:57 +0000 (20:49 +0100)] 
Fix memory leak in ntlm_support

Not really important but prevents running the NTLM
t_client tests with ASAN enabled.

Change-Id: If472398d4ff8323de485f084a07160b365dfc501
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20241209194957.358-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30049.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoFix port-share journal doc
corubba [Sat, 7 Dec 2024 23:19:35 +0000 (00:19 +0100)] 
Fix port-share journal doc

Filename and content descriptions were switched.

Signed-off-by: corubba <corubba@gmx.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <d7c52354-8263-4423-8a4f-39bab3bd4d97@gmx.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30036.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoFix IPv6 in port-share journal
corubba [Sat, 7 Dec 2024 23:17:05 +0000 (00:17 +0100)] 
Fix IPv6 in port-share journal

getpeername() and getsockname() will truncate the result if it is
larger than the passed-in length. Because here always the size of the
`sa` IPv4 union member was passed in, all larger (aka IPv6) results
were truncated. Instead use the size of the `addr` union, which is the
maximum size of all union members.

The bug was introduced in 0b6450c9.

Trac: #1358

Signed-off-by: corubba <corubba@gmx.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <8de5660b-d917-4092-8871-250495d8c7a4@gmx.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30035.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoFix some formatting related to if/else and macros
Frank Lichtenheld [Thu, 5 Dec 2024 21:41:58 +0000 (22:41 +0100)] 
Fix some formatting related to if/else and macros

Make it clearer where the blocks are.

Change-Id: If645c3faf149bac82167a91be13541b30a1b8d6a
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20241205214158.23542-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30027.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 months agoHaiku: Add calls to manage routing table
Alexander von Gluck [Thu, 5 Dec 2024 17:24:59 +0000 (18:24 +0100)] 
Haiku: Add calls to manage routing table

Note: the full functionality of these changes depends on
      https://review.haiku-os.org/c/haiku/+/8592

Signed-off-by: Alexander von Gluck <alex@terarocket.io>
Acked-by: Gert Doering <gert@greenie.muc.de>
Change-Id: I1a22724f28c5cd47f6df178b49f44087d7c2b6fd
Message-Id: <20241205172459.4783-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30023.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 months agomacOS: Assume that net/if_utun.h is always present
Frank Lichtenheld [Thu, 28 Nov 2024 14:27:08 +0000 (15:27 +0100)] 
macOS: Assume that net/if_utun.h is always present

Has been present in all releases since 10.7,
i.e. about 13 years ago. At this point the check
just makes the code uglier for no actual benefit.

Change-Id: I41eeae35ab23d9fb2512f33086f20f54c2d4f6df
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20241128142708.14665-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29963.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 months agoVarious typo fixes
Frank Lichtenheld [Thu, 28 Nov 2024 12:30:16 +0000 (13:30 +0100)] 
Various typo fixes

This collects some minor typo fixes that are not
worth each their own commit.

Fixes: OpenVPN/openvpn#644
Fixes: OpenVPN/openvpn#442
Change-Id: Ifad21a2841e97e910775f3618ddac1c483d74b65
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241128123016.10444-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29956.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 months agoHaiku: Introduce basic platform / tun support
Alexander von Gluck [Thu, 28 Nov 2024 10:15:38 +0000 (11:15 +0100)] 
Haiku: Introduce basic platform / tun support

* Special thanks to Sean Brady's hard work in GSoC 2023 towards creating
  a TUN/TAP driver for Haiku!
* More kudos to Augustin Cavalier for making it functional :-)

Signed-off-by: Alexander von Gluck <alex@terarocket.io>
Acked-by: Gert Doering <gert@greenie.muc.de>
Change-Id: I9a278374f492a538f0c174ced1746c3b1f82b8c9
Message-Id: <20241128101538.12810-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29947.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 months agoFix wrong doxygen comments
Frank Lichtenheld [Tue, 26 Nov 2024 10:26:51 +0000 (11:26 +0100)] 
Fix wrong doxygen comments

Add some missing "<" to trailing comments
to make sure they apply to the correct line.

Change-Id: Ib88ce925b20c5912de489ef1b62615c4b87d365c
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20241126102651.18905-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29897.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 months agoChange --reneg-bytes and --reneg-packets to 64 bit counters
Arne Schwabe [Mon, 11 Nov 2024 09:40:33 +0000 (10:40 +0100)] 
Change --reneg-bytes and --reneg-packets to 64 bit counters

reneg-bytes can currently only specify up to a maximum of 2GB.
This makes it even problematic to use without extended counters.

Change-Id: I993e7fc5609955d271e74370affc2eea340a1e2d
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241111094033.16073-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29744.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 months agoMove should_trigger_renegotiation into its own function
Arne Schwabe [Mon, 11 Nov 2024 07:43:55 +0000 (08:43 +0100)] 
Move should_trigger_renegotiation into its own function

The if statement has become quite large and unreadable. Reformat it
and move it to a separate function.

Change-Id: I210fa255921e7115bd66ba5f3e431562552e3335
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241111074355.17918-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29740.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 months agositnl: replace NLMSG_TAIL macro with noinline function
Antonio Quartulli [Wed, 6 Nov 2024 13:17:03 +0000 (14:17 +0100)] 
sitnl: replace NLMSG_TAIL macro with noinline function

The NLMSG_TAIL macro is confusing gcc when compiling with -O3, leading
to warnings like:

networking_sitnl.c:143:9: warning: writing 4 bytes into a region of size 0 [-Wstringop-overflow=]
  143 |         memcpy(RTA_DATA(rta), data, alen);
      |         ^
networking_sitnl.c:101:21: note: at offset [72, 88] into destination object â€˜n’ of size 16
  101 |     struct nlmsghdr n;
      |                     ^

Replacing the macro with a function is also not effective because gcc
will inline it and get confused again.

The only way out is to write a function that never gets inline'd and
replace the macro with it.

Tested on linux with gcc and clang.

Change-Id: I9306a590a10a7d5cba32abe06d269494fec41ba6
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20241106131705.11069-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29710.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 months agoRemove support for compression on send
Frank Lichtenheld [Fri, 8 Nov 2024 17:38:51 +0000 (18:38 +0100)] 
Remove support for compression on send

We can't disable compression support on receive because
that would break too many configurations out there. But
we can remove the support for compressing outgoing traffic,
it was disabled by default anyway.

Makes "--allow-compression yes" an alias for
"--allow-compression asym" and removes all resulting dead code.

Change-Id: I402ba016b75cfcfec4fc8b2b01cc4eca7e2bcc60
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241108173851.436-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29718.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 months agosend uname() release as IV_PLAT_VER= on non-windows versions
Gert Doering [Mon, 4 Nov 2024 08:58:08 +0000 (09:58 +0100)] 
send uname() release as IV_PLAT_VER= on non-windows versions

This is highly system specific, as the content of the uname()
structure elements is not specified very well - uname(3) says:

      release       Release level of the operating system

which translates to "IV_PLAT_VER=13.3-RELEASE-p6" (FreeBSD) or
"IV_PLAT_VER=22.6.0" (macOS) - the latter being the "Mach Kernel
version", not what Apple calls the OS.

It's still useful if a server operator needs to keep track of
client versions (and the GUI does not set the corresponding
environment variable, which neither Tunnelblick nor NM do).

v2: manpage amendments
v3: whitespace
v4: reword manpage

Github: OpenVPN/openvpn#637

Change-Id: Id2b0c5a517f02e5c219fea2ae3ef2bdef7690169
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20241104085808.17039-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29699.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 months agoAdd calls to nvlist_destroy to avoid leaks
Rémi Farault [Tue, 29 Oct 2024 11:06:35 +0000 (12:06 +0100)] 
Add calls to nvlist_destroy to avoid leaks

Some memory leaks were detected by valgrind on the openvpn daemon, using
DCO mode on a FreeBSD platform.  The leaks are caused by missing
nvlist_destroy calls in the file dco_freebsd.c.

Calls to nvlist_destroy were added, sometimes using local variables to
store nvlist pointers temporarly.  A valgrind run on the updated daemon
confirmed that  the leaks were gone.

Github: OpenVPN/openvpn#636
Signed-off-by: Rémi Farault <remi.farault@stormshield.eu>
Acked-by: Kristof Provost <kp@freebsd.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <f8845c0c5aa74e5bab537463249a251d@stormshield.eu>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29701.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 months agoRefuse clients if username or password is longer than USER_PASS_LEN
Arne Schwabe [Mon, 28 Oct 2024 13:55:04 +0000 (14:55 +0100)] 
Refuse clients if username or password is longer than USER_PASS_LEN

When OpenVPN is compiled without PKCS11 support USER_PASS_LEN is 128
bytes. If we encounter a username larger than this length, we would
only read the 2 bytes length header of the username/password.  We did
then also NOT skip the username or password field meaning that we would
continue reading the rest of the packet at the wrong offset and get
garbage results like not having peerinfo and then rejecting a client
because of no common cipher or missing data v2 support.

This will tell the client that username/password is too regardless
of whether password/username authentication is used.  This way we
do not leak if username/password authentication is active.

To reproduce this issue have the server compiled with a USER_PASS_LEN
set to 128 (e.g. without pkcs11 or manually adjusting the define) and
have the client with a larger USER_PASS_LEN to actually be able to
send the larger password. The server must also be set to use only
certificate authentication while the client must use certificates
and auth-user-pass because otherwise the user/pass verification will
reject the empty credentials.

Using the openvpn3 test client with overlong username/password also
works.

Change-Id: I60f02c919767eb8f1b95253689a8233f5f68621d
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241028135505.28651-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29675.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 months agot_server_null: use wait instead of marker files
Samuli Seppänen [Sat, 26 Oct 2024 09:25:14 +0000 (11:25 +0200)] 
t_server_null: use wait instead of marker files

By using wait in a more inventive way we can avoid using a marker file
to detect the "server could not be killed gracefully" situation.

Change-Id: Ib385080e1dd1c3046c54e6267db8aa7d5c09e2fb
Signed-off-by: Samuli Seppänen <samuli.seppanen@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241026092515.30559-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29664.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 months agot_server_null: forcibly kill misbehaving servers
Samuli Seppänen [Fri, 25 Oct 2024 10:36:31 +0000 (12:36 +0200)] 
t_server_null: forcibly kill misbehaving servers

Change-Id: Ic0f98cd3b87a7b86e032e63167ac9036f7c08fcb
Signed-off-by: Samuli Seppänen <samuli.seppanen@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241025103632.4413-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29655.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 months agot_server_null: persist test log files
Samuli Seppänen [Thu, 24 Oct 2024 13:32:17 +0000 (15:32 +0200)] 
t_server_null: persist test log files

The goal is to help debug issues with t_server_null. The immediate goal
is to be able to debug server startup issues encountered on some of the
*BSD platforms.

Change-Id: I49f1e7d25edb62bf202ffceb45dedc213f2eafdd
Signed-off-by: Samuli Seppänen <samuli.seppanen@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241024133220.4864-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/search?l=mid&q=20241024133220.4864-1-gert@greenie.muc.de
URL: https://gerrit.openvpn.net/c/openvpn/+/776
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 months agoio_work: pass event_arg object to event handler in case of socket event
Antonio Quartulli [Wed, 23 Oct 2024 14:20:30 +0000 (16:20 +0200)] 
io_work: pass event_arg object to event handler in case of socket event

In order to allow the code to work with multiple listening sockets
it is essential to allow the generic multi_io event handler
to distinguish between the various socket objects.

This can be achieved by passing an event_arg object that contains
a pointer to the link_socket.

This code path is used on clients as well as UDP servers.

Change-Id: I7ebf0d4fb2a23278e16003b2e35598178155d658
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Message-Id: <20241023142030.731-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29625.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 months agoio_work: convert shift argument to uintptr_t
Antonio Quartulli [Wed, 23 Oct 2024 08:42:08 +0000 (10:42 +0200)] 
io_work: convert shift argument to uintptr_t

Instead of passing the shift argument as pointer, pass
directly its integer value. This will allow the code to
distinguish a shift value from a real object pointer,
like we already do in multi_tcp_process_io().

This change will allow us later to pass an event_arg
object as event handler argument instead of a simple
integer value.

Change-Id: Ib583bf17e35b14aed78fd8217b6e71e8c2b78089
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20241023084208.12317-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29604.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 months agopass link_socket object to i/o functions
Antonio Quartulli [Wed, 23 Oct 2024 08:34:44 +0000 (10:34 +0200)] 
pass link_socket object to i/o functions

In order to prepare the code to work with distinct sockets,
it is essential that i/o functions do not operate on any
hard-coded socket object (i.e. c->c2.link_socket).

This patch changes all the low-level i/o functionis to work
with a socket specified as argument rather than a fixed one.

Change-Id: I8eae2d3356bbcc5d632eeb4fbe80de8009d9b40d
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20241023083444.27951-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29603.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 months agoFix for msbuild/mingw GHA failures
Gianmarco De Gregori [Wed, 23 Oct 2024 11:39:23 +0000 (13:39 +0200)] 
Fix for msbuild/mingw GHA failures

Commit cd8e25a6e9 removed a variable because it looked as if
used only once anyway (1 assignment, 1 usage) - overlooking that
on _WIN32 it's changed to NULL, which wasn't adjusted...

This fix restores the wiped out "unsigned int *persistent" in
multi_tcp_wait(), undoing this particular change of the previous
commit.

Change-Id: I8526aadb5151ddc997c836d5a691bcdfee700938
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241023113923.7420-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29612.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 months agoevent/multi: add event_arg object to make event handling more generic
Antonio Quartulli [Wed, 23 Oct 2024 08:08:52 +0000 (10:08 +0200)] 
event/multi: add event_arg object to make event handling more generic

In order to prepare the event handling code to deal with multiple
listening sockets, we have to make sure that it is possible to
distinguish which of these sockets have been poked by an incoming
connection request.

To achieve that, this patch changes the object being passed as
event handler argument, from a "partly integer-evaluated variable"
to a full struct with a proper type attribute.

This struct will allow the code to carry around the particular
listening socket where the connection is being established.

This change affects the TCP server code path only as UDP servers
use only one socket to handle all clients.

Change-Id: Icd7f6a2ad350cdc2312b3e80fa0dbdd7e4311d2e
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20241023080853.3710-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29602.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 months agoRemove unused methods write_key/read_key
Arne Schwabe [Fri, 18 Oct 2024 06:31:23 +0000 (08:31 +0200)] 
Remove unused methods write_key/read_key

These were used in the key-method 1 that we remove by commit
36bef1b52 in 2020.  That commit unfortunately missed that these
methods were only used for directly sending/receiving key material
over the control channel.

Change-Id: Ib480e57b62ea33f2aea52bee895badaf5607b72d
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241018063123.11631-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29595.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 months agoRemove a large number of unused structs and functions
Arne Schwabe [Fri, 18 Oct 2024 06:37:17 +0000 (08:37 +0200)] 
Remove a large number of unused structs and functions

These have been found by Clion's Inspect Code functionality and have
been verified by hand.  A few functions like buf_read_u32 have been
kept since they still feel being useful while currently not being used.

Change-Id: I0d96ee06c355c6a5ce082af23921e329d3efae33
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241018063717.14629-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29594.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 months agoImprove data channel crypto error messages
Steffan Karger [Thu, 17 Oct 2024 06:49:55 +0000 (08:49 +0200)] 
Improve data channel crypto error messages

 * Make decryption error messages better understandable.
 * Increase verbosity level for authentication errors, because those can
   be expected on bad connections.

Change-Id: I0fd48191babe4fe5c56f10eb3ba88182ffb075d1
Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: MaxF <max@max-fillinger.net>
Message-Id: <20241017064955.23959-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29569.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 months agoGHA: Simplify macOS builds
Frank Lichtenheld [Tue, 15 Oct 2024 20:56:43 +0000 (22:56 +0200)] 
GHA: Simplify macOS builds

Reduce redundant configuration.

Change-Id: Ie922ce67685228eb7043749a7f1a61a33be678d2
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Acked-by: Yuriy Darnobyt <yura.uddr@gmail.com>
Message-Id: <20241015205643.25779-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29552.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 months agoGHA: Update macOS runners
Frank Lichtenheld [Tue, 15 Oct 2024 20:56:27 +0000 (22:56 +0200)] 
GHA: Update macOS runners

Remove macos-12, not supported anymore.
Add macos-15, runner is available in Beta status.

Change-Id: Ibaa591904095a824df2c0c5aaff73687e0af24fe
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Acked-by: Yuriy Darnobyt <yura.uddr@gmail.com>
Message-Id: <20241015205627.25644-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29551.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agot_client.sh: conditionally skip ifconfig+route check
Gert Doering [Sat, 28 Sep 2024 20:05:08 +0000 (22:05 +0200)] 
t_client.sh: conditionally skip ifconfig+route check

For --dev null or --dev-type af_unix:lwipopenvn tests, there will be
no visible change to ifconfig or route output, so tests will fail
("how can this be?").  Set EXPECT_IFCONFIG4_<n>=- to skip this
check.

(Simply leaving both EXPECT_IFCONFIG* vars empty and using that as
trigger would interfere with the magic from commit df0b00c25)

v2: fix string-equal comparison

Change-Id: Iec1953415afb53755488dd44407568e72d28e854
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20240928200508.23747-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29473.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agodco: better naming for function parameters
Lev Stipakov [Fri, 27 Sep 2024 09:30:45 +0000 (11:30 +0200)] 
dco: better naming for function parameters

Current naming (remote_in4/6) is confusing, since
those are in fact VPN IPv4/v6 addresses and not
related to remote at all.

Change-Id: I101bbc9f682375ec733bca10b52da82f0abfec27
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20240927093045.22753-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29460.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoGHA: Pin dependencies
Frank Lichtenheld [Fri, 27 Sep 2024 09:32:05 +0000 (11:32 +0200)] 
GHA: Pin dependencies

Done by renovate. Updates will also be handled by
renovate.

This makes the builds slightly more deterministic and
removes some potential supply-chain attack vectors.

GitHub: #610

Change-Id: I92dfbc3a0cc347a51892600bf02b501295ce612b
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Yuriy Darnobyt <yura.uddr@gmail.com>
Message-Id: <20240927093205.22981-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29461.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoRemove null check after checking for checking for did_open_tun
Arne Schwabe [Wed, 25 Sep 2024 15:11:04 +0000 (17:11 +0200)] 
Remove null check after checking for checking for did_open_tun

If we indicate that the tun device has been opened the c1.tuntap struct
is guaranteed to be defined. This extra null check is something that
Coverity flags as we access a do a null check after already accessing fields
of tuntap

Change-Id: I9966636163c7dfa208d26f1cadbf5b81937f3a34
Signed-off-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240925151104.13036-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29447.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoFix check for CMake not detecting struct cmsg
Arne Schwabe [Wed, 25 Sep 2024 15:13:42 +0000 (17:13 +0200)] 
Fix check for CMake not detecting struct cmsg

This check seems to have never worked and on Linux we hard coded
the check instead. Remove this hard coded assumption and use a
working check based on check_struct_has_member instead.

This is has the side-effect of port-sharing being enabled on macOS
when compiled with cmake.

Change-Id: Ia020c696f63a2a317f001c061b2ab4da69977750
Signed-off-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20240925151342.13307-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29448.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoEnsure that the AF_UNIX socket pair has at least 65k of buffer space
Arne Schwabe [Wed, 25 Sep 2024 06:30:16 +0000 (08:30 +0200)] 
Ensure that the AF_UNIX socket pair has at least 65k of buffer space

Without this change, pinging a lwipovpn client with something like a
3000 byte payload on macOS often fails as the default buffer sizes on
macOS are 2048 for send and 4096 for receive.

Change-Id: Ice015df81543c01094479929f0cb3075ca4f3813
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240925063016.22532-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29413.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoAutomatically enable ifconfig-exec/route-exec behaviour for afunix tun/tap
Arne Schwabe [Tue, 24 Sep 2024 13:14:37 +0000 (15:14 +0200)] 
Automatically enable ifconfig-exec/route-exec behaviour for afunix tun/tap

Change-Id: I0a2957699757665d70514ba7cafe833443018ad6
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240924131437.22294-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/search?l=mid&q=20240924131437.22294-1-gert@greenie.muc.de
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoUse print_tun_backend_driver instead of custom code to print type
Arne Schwabe [Tue, 24 Sep 2024 12:55:13 +0000 (14:55 +0200)] 
Use print_tun_backend_driver instead of custom code to print type

Also show the device type that we opened always instead of certain
conditions only.

Change-Id: Ib8f12516dbe294e21d3fed77478fb7660d4600c1
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240924125513.10710-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29386.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoChange dev null to be a driver type instead of a special mode of tun/tap
Arne Schwabe [Tue, 24 Sep 2024 12:43:28 +0000 (14:43 +0200)] 
Change dev null to be a driver type instead of a special mode of tun/tap

Change-Id: I5987ebb7c38ab176eed7efc004ea54f606a77a12
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240924124328.3037-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29384.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoIntroduce DRIVER_AFUNIX backend for use with lwipovpn
Arne Schwabe [Tue, 24 Sep 2024 11:01:29 +0000 (13:01 +0200)] 
Introduce DRIVER_AFUNIX backend for use with lwipovpn

lwipovpn is a using lwip TCP/IP implementation with an AF_UNIX
implementation to emulate a tun/tap device without messing with the
TCP/IP stack of the host.

For more information about lwipovpn see https://github.com/OpenVPN/lwipovpn

Change-Id: I65099ef00822d08fd3f5480c80892f3bf86c56e7
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240924110130.3910-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29379.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoMove to common backend_driver type in struct tuntap
Arne Schwabe [Sun, 22 Sep 2024 20:37:49 +0000 (22:37 +0200)] 
Move to common backend_driver type in struct tuntap

With the introduction of utun on macOS and DCO on Linux, FreeBSD and
Windows, a lot of platforms have now more than one driver/backend for
the tun interface but each one uses a different mechanism. Unify these
approach with using a common enum that defines the driver_type.

Change-Id: I8c0e9f32b235cb262ca2be6aac8d520e49b30d74
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240922203749.9802-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29352.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agomake t_server_null 'server alive?' check more robust
Gert Doering [Wed, 18 Sep 2024 16:29:17 +0000 (18:29 +0200)] 
make t_server_null 'server alive?' check more robust

- use "$RUN_SUDO kill -0 $pid" to test if a given process is running, not
  "ps -p $pid" - the latter will not work if security.bsd.see_other_uids=0
  is set

- produce proper error messages if pid files can not be found or are
  empty at server shutdown time

Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20240918162917.6809-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29314.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agosocket: Change return types of link_socket_write* to ssize_t
Frank Lichtenheld [Wed, 18 Sep 2024 20:48:44 +0000 (22:48 +0200)] 
socket: Change return types of link_socket_write* to ssize_t

This is the actual return value of send/sendto/sendmsg.
We will leave it to the single caller of link_socket_write()
to decide how to map that to the int buffer world. For now
just cast it explicitly.

Change-Id: I7852c06d331326c1dbab7b642254c0c00d4cebb8
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240918204844.2820-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29323.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoconfigure: Review use of standard AC macros
Frank Lichtenheld [Wed, 18 Sep 2024 20:45:50 +0000 (22:45 +0200)] 
configure: Review use of standard AC macros

- Increase required version to 2.60 since that is documented
  minimum version for AC_USE_SYSTEM_EXTENSIONS
- Remove obsolete macros AC_C_CONST and AC_C_VOLATILE. They
  are noops on every compiler we support.
- Add explicit call to AC_PROG_CC. We get this implictly as
  dependency of other macros, but it is nicer to have it
  explicitely as well.
- A few typo and whitespace fixes.

Change-Id: I7927a572611b7c1dc0b522fd6cdf05fd222a852d
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240918204551.2530-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29321.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoconfigure: Handle libnl-genl and libcap-ng consistent with other libs
Frank Lichtenheld [Tue, 17 Sep 2024 13:32:53 +0000 (15:32 +0200)] 
configure: Handle libnl-genl and libcap-ng consistent with other libs

Do not communicate any of the flags via the global
CFLAGS and LIBS, so that users are not confused when
overriding them on the command line.

Github: closes OpenVPN/openvpn#586
Change-Id: I39a6f58b11b922f5dbd3e55a5bc8574eda8a83fe
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240917133253.19616-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29282.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoAvoid SIGUSR1 to SIGHUP remapping when the configuration is read from stdin
Arne Schwabe [Fri, 19 Jul 2024 13:10:16 +0000 (15:10 +0200)] 
Avoid SIGUSR1 to SIGHUP remapping when the configuration is read from stdin

If the configuration is read from stdin, we cannot reread the configuration
as stdin provides the configuration only once. So whenever we hit the
"close_context usr1 to hup" logic, the OpenVPN process will fail as tries
to restart with an empty configuration.

While OpenVPN tries to block  USR1 from normal unix signal, I have observed
cases in my app which sends USR1 from management interface where the
CC_HARD_USR1_TO_HUP logic is trigger and breaking the OpenVPN process.

Change-Id: Icfc179490d6821e22d14817941fb0bad667c713f
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20240719131016.75042-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28941.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoRoute: remove incorrect routes on exit
Gianmarco De Gregori [Wed, 21 Feb 2024 11:18:14 +0000 (12:18 +0100)] 
Route: remove incorrect routes on exit

Implemented a safeguard to verify the returned value
from add_route3() when the default gateway is not a local
remote host.

Prior to this implementation, RT_DID_LOCAL flag was
erroneously set even in case of add_route3() failure.
This problem typically occurs when there's no default
route and the --redirect-gateway def1 option is specified,
and in case of reconnection makes it impossible for the client
to reobtain the route to the server.
This fix ensures OpenVPN accurately deletes the appropriate
route on exit by properly handling add_route3() return value.

Trac: #1457
Change-Id: I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20240221111814.942965-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28290.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoFix check_addr_clash argument order
Ralf Lici [Tue, 17 Sep 2024 09:14:33 +0000 (11:14 +0200)] 
Fix check_addr_clash argument order

In init_tun() make sure to pass the --local and --remote addresses in
the host order so that they can be compared to the --ifconfig addresses.

Change-Id: I5adbe0a79f078221c4bb5f3d39391a81b4d8adce
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20240917091433.24092-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29261.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoMake read/write_tun_header static
Arne Schwabe [Mon, 16 Sep 2024 13:34:35 +0000 (15:34 +0200)] 
Make read/write_tun_header static

These functions are not used outside tun.c

Change-Id: I028634dba74a273c725b0beb16b674897b3c23fa
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240916133436.29943-1-gert@greenie.muc.de>
Signed-off-by: Gert Doering <gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29249.html

10 months agoGHA: Enable t_server_null tests
Frank Lichtenheld [Thu, 12 Sep 2024 17:49:10 +0000 (19:49 +0200)] 
GHA: Enable t_server_null tests

Change-Id: I86203b8f9a6d3cfc5e56d3ce9452af694fd11011
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240912174910.21058-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29231.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agodco: mark peer as deleted from kernel after receiving CMD_DEL_PEER notification
Antonio Quartulli [Thu, 12 Sep 2024 16:53:39 +0000 (18:53 +0200)] 
dco: mark peer as deleted from kernel after receiving CMD_DEL_PEER notification

some extra DCO calls may be made after receiving the DEL_PEER
notification (i.e. due to timeout), but this will result in
an error message due to the peer having disappeared already.

An extra call might be, for example, an explicit DEL_PEER
in the attempt of cleaning the peer state.

For this reason, inform userspace that there is no peer in
kernel anymore and prevent errors which may result confusing.

Change-Id: Ife50e37cd49d55ec81a70319a524ffeaf0625a56
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20240912165339.21058-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29226.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoRemove check for anonymous unions from configure and cmake config
Arne Schwabe [Wed, 10 Jul 2024 16:02:38 +0000 (18:02 +0200)] 
Remove check for anonymous unions from configure and cmake config

Anonymous unions/structs are technically a custom GNU C99 feature but
was already widely supported by other compilers. With C11 this feature
has become a standard feature so all compilers nowadays support it.

Change-Id: I1ef5f6f21f0135a628a63553c39515fa4549ce87
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20240710160238.190189-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28914.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agotun: removed unnecessary route installations
Marco Baffo [Thu, 12 Sep 2024 14:24:21 +0000 (16:24 +0200)] 
tun: removed unnecessary route installations

Removed superfluous calls to 'add_route_ipv6' for adding ipv6 routes after tun opening in OpenBSD, NetBSD and Darwin.

Change-Id: I235891212b15277349810913c9c1763da5c48587
Signed-off-by: Marco Baffo <marco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240912142421.703-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29217.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoGHA: Update dependency Mbed-TLS/mbedtls to v3.6.1
Frank Lichtenheld [Wed, 11 Sep 2024 14:42:31 +0000 (16:42 +0200)] 
GHA: Update dependency Mbed-TLS/mbedtls to v3.6.1

Requires submodule checkout.

Change-Id: I86ceceb4e1c716b33c6c6ec8853eca0fb4b394f1
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20240911144231.32553-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29208.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoDo not stop reading from file/uri when OPENSSL_STORE_load() returns error
Selva Nair [Wed, 11 Sep 2024 10:49:41 +0000 (12:49 +0200)] 
Do not stop reading from file/uri when OPENSSL_STORE_load() returns error

OPENSSL_STORE_load() can error and return NULL even when the file or URI
still has readable objects left.

Fix by iterating until OPENSSL_STORE_eof(). Also clear such errors to avoid
misleading messages printed at the end by crypto_print_openssl_errors().

Change-Id: I2bfa9ffbd17d0599014d38b2a2fd319766cdb1e3
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20240911104941.19429-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29187.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agogenerate_auth_token: simplify code
Frank Lichtenheld [Tue, 10 Sep 2024 17:00:05 +0000 (19:00 +0200)] 
generate_auth_token: simplify code

The previous code went through some hoops
to avoid compiler warnings. But there is
a much easier way by just telling it
exactly what you want to do.

Also fix typo in variable name while I'm
here.

Change-Id: Icc86334b26ba1fcc20f4cd03644018d1d16796e3
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20240910170005.5586-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29178.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoVarious fixes for -Wconversion errors
Frank Lichtenheld [Tue, 10 Sep 2024 12:20:08 +0000 (14:20 +0200)] 
Various fixes for -Wconversion errors

These are all fixes I considered "safe". They either

- Have sufficient checks/shifts for a cast to be safe
- Fix the type of a variable without requiring code changes
- Are in non-critical unittest code

v2:
 - add min_size instead of abusing min_int
v6:
 - remove change of return value of link_socket_write.
   Move to separate patch.

Change-Id: I6818b153bdeb1eed65870af99b0531e95807fe0f
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20240910122008.23507-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29172.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoFix more of uninitialized struct user_pass local vars
Selva Nair [Mon, 9 Sep 2024 20:48:29 +0000 (16:48 -0400)] 
Fix more of uninitialized struct user_pass local vars

Not all of these touch uninitialzed members of the struct, but that
could change in future.

Change-Id: I71bc847b48da54b70f60ccd7c4521ec699daf9cb
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240909204829.10379-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29152.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoEnsures all params are ready before invoking dco_set_peer()
Gianmarco De Gregori [Fri, 6 Sep 2024 14:57:45 +0000 (16:57 +0200)] 
Ensures all params are ready before invoking dco_set_peer()

In UDP case, on a p2mp server, dco_set_peer() is currently called
at the wrong time since the mssfix param is calculated later on in
tls_session_update_crypto_params_do_work().

Move the dco_set_peer() inside tls_session_update_crypto_params_do_work(),
and remove p2p_set_dco_keepalive() to avoid calling dco_set_peer()
twice on the client side.

This way, we'll ensure that all crypto and frame params are properly
initialized and if an update occurs DCO will be notified.

Change-Id: Ic8538e734dba53cd43fead3961e4401c8037e079
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20240906145745.67596-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29086.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agotun: use is_tun_p2p more consistently
Frank Lichtenheld [Fri, 6 Sep 2024 16:25:14 +0000 (18:25 +0200)] 
tun: use is_tun_p2p more consistently

Using "tun" as the variable name for the return of
is_tun_p2p is probably a historical accident. But
it has actual consequences in that the other code
often seems to assume that it does less checks
than it actually does.

Use "tun_p2p" as the variable name and remove checks
that are not required. Also use is_tun_p2p in more
places.

Change-Id: Ice8b95f953c3f7e71657a78ea12b02a08c60aa67
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20240906162514.78671-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29091.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agotests/unit_tests/openvpn/test_auth_token.c: handle strdup errors
Ilia Shipitsin [Mon, 8 Jul 2024 21:08:22 +0000 (23:08 +0200)] 
tests/unit_tests/openvpn/test_auth_token.c: handle strdup errors

Signed-off-by: Ilia Shipitsin <chipitsine@gmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20240708210912.566-6-chipitsine@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28882.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agosample/sample-plugins/defer/multi-auth.c: handle strdup errors
Ilia Shipitsin [Mon, 8 Jul 2024 21:08:19 +0000 (23:08 +0200)] 
sample/sample-plugins/defer/multi-auth.c: handle strdup errors

Signed-off-by: Ilia Shipitsin <chipitsine@gmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20240708210912.566-3-chipitsine@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28886.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agosrc/openvpn/init.c: handle strdup failures
Ilia Shipitsin [Mon, 8 Jul 2024 21:08:18 +0000 (23:08 +0200)] 
src/openvpn/init.c: handle strdup failures

Signed-off-by: Ilia Shipitsin <chipitsine@gmail.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240708210912.566-2-chipitsine@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28884.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 months agoAdd test for static-challenge concatenation option
Selva Nair [Fri, 30 Aug 2024 14:18:24 +0000 (10:18 -0400)] 
Add test for static-challenge concatenation option

Change-Id: I41f6c1f7acb58f30fc4db0e32505018f64fcad28
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20240830141824.108599-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29054.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>