]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
2 years agovcpkg-ports/pkcs11-helper: Make compatible with mingw build
Frank Lichtenheld [Fri, 31 Mar 2023 15:42:12 +0000 (17:42 +0200)] 
vcpkg-ports/pkcs11-helper: Make compatible with mingw build

Annoyingly this requires custom vcpkg triplets because
the mingw toolchain definition and the vcpkg_configure_make
function use incompatible default triplets (-pc-mingw32 vs
-w64-mingw32).

Change-Id: I4e671938220e9bfd798f91819f34b6f8ceaa45f5
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230331154214.613245-2-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26572.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoFix compile error on TARGET_ANDROID
Arne Schwabe [Mon, 17 Apr 2023 13:40:46 +0000 (15:40 +0200)] 
Fix compile error on TARGET_ANDROID

Commit 3132bead49 accidentially was submitted with a missing semicolon
at the end of the line. Whoops.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230417134046.81761-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26593.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agofix typo in help text: --ignore-unknown-option
Michael Nix [Mon, 17 Apr 2023 12:54:46 +0000 (14:54 +0200)] 
fix typo in help text: --ignore-unknown-option

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230417125446.27247-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26592.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agotests: do not include t_client.sh in dist
Frank Lichtenheld [Tue, 18 Apr 2023 13:49:41 +0000 (15:49 +0200)] 
tests: do not include t_client.sh in dist

It is generated from t_client.sh.in by configure,
so no need to ship it. Due to the dependency on
the configuration it also might break reproducibility
of the dist tarball.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230418134941.86637-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26596.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoman page: Remove cruft from --topology documentation
Frank Lichtenheld [Wed, 3 May 2023 13:59:21 +0000 (15:59 +0200)] 
man page: Remove cruft from --topology documentation

None of this is likely relevant for a current reader.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230503135922.54871-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26621.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoDCO: support key rotation notifications
Kristof Provost [Fri, 14 Apr 2023 09:42:27 +0000 (11:42 +0200)] 
DCO: support key rotation notifications

Allow the kernel driver to notify us that it's time to renegotiate keys.
The intent is to avoid IV re-use after 2^32 packets.

This is a first draft intended for discussion. The accompanying kernel
change for FreeBSD can be found in https://reviews.freebsd.org/D39570

Signed-off-by: Kristof Provost <kprovost@netgate.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20230414094227.9153-1-kprovost@netgate.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26590.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoFormat Windows error message in Unicode
Selva Nair [Tue, 18 Apr 2023 14:14:46 +0000 (10:14 -0400)] 
Format Windows error message in Unicode

- We assume that all text passed to the management interface
  and written to log file are in Unicode (UTF-8). This is broken by
  the use of the ANSI version of FormatMessage() for Windows error
  messages. Fix by using FormatMessageW() and converting the UTF-16
  result to UTF-8.

v2: assign return value of FormatMessageW() to DWORD, not int

Github: fixes OpenVPN/openvpn#319

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230418141446.1755363-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26598.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAdd Apache2 linking with for new commits
Arne Schwabe [Wed, 26 Apr 2023 09:49:31 +0000 (11:49 +0200)] 
Add Apache2 linking with for new commits

After first round of mailing people with more than 10 commits we have
almost all committers have agreed. This put this license in the realm
of having a realistic change to work. Had any of these contributers
disagreed, rewriting all their code might have been not feasible.

The rationale of adding this exception now is to avoid having to
have a second round of agreement for new contributers and ensure
that all new code will include the exemption.

patch v2: add explaination and use exception rather than excemption
patch v3: actually send v3

Change-Id: Ide83f914f383b53ef37ddf628e4da5a78e241bf0
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20230426094931.1168078-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26610.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoRemove unused variable line
Arne Schwabe [Sun, 30 Apr 2023 17:22:02 +0000 (19:22 +0200)] 
Remove unused variable line

The newer compilers started to complain about this.

Change-Id: I784def4d941b7d21c7979f84f8681719c9ff7a53
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230430172202.206528-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26612.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodoc: run rst2* with --strict to catch warnings
Frank Lichtenheld [Fri, 31 Mar 2023 13:24:29 +0000 (15:24 +0200)] 
doc: run rst2* with --strict to catch warnings

Basically -Werror for docutils.

Fix all issues raised by this. The following issue
classes were reported:

Possible title underline, too short for the title.
Treating it as ordinary text because it's so short.
(:: at the start of the line directly below text,
either add empty line of merge into : on previous line)

Enumerated list start value not ordinal-1
(error in numbering)

Change-Id: Id3b0f7be4602f70115c60e6ddb89f6ed58e94e64
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230331132429.601635-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26567.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoSupport of DNS domain for DHCP-less drivers
Lev Stipakov [Thu, 6 Apr 2023 07:15:46 +0000 (10:15 +0300)] 
Support of DNS domain for DHCP-less drivers

We set DNS domain either via interactve service or DHCP.
When interactive service is not used, for example,
when profiles are started by OpenVPNService, this option
is not working for DCO and wintun.

This implements setting DNS domain via WMIC command,
similar to implementation in interactive service.
This is done when:

 - interactive service is not used

 - DHCP is not used (ip-win32 is either NETSH or IPAPI,
   or IPv4 address is not pushed)

Github: fixes OpenVPN/openvpn#306

Change-Id: Ic72a4ecd0414c0d7bf013415f52640fd122cb739
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20230406071546.1056-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26582.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoversion.sh: remove
Frank Lichtenheld [Thu, 30 Mar 2023 09:42:26 +0000 (11:42 +0200)] 
version.sh: remove

This was added back in commit
6187644b660ce284d0a706811eae2dce7cb411b2
to support the NSIS windows installer.

It is now unused.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230330094226.487951-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26560.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoDo not include net/in_systm.h
Frank Lichtenheld [Thu, 30 Mar 2023 09:42:15 +0000 (11:42 +0200)] 
Do not include net/in_systm.h

This only defines three types and none of them is
used anywhere in our source code.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230330094215.487924-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26559.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agovcpkg: request "tools" feature of openssl for MSVC build
Frank Lichtenheld [Thu, 30 Mar 2023 10:15:36 +0000 (12:15 +0200)] 
vcpkg: request "tools" feature of openssl for MSVC build

We need this for the MSI build. Previously this was enabled
by default.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230330101536.533080-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26561.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoMake cert_data.h and test_cryptoapi/pkcs11.c MSVC compliant
Selva Nair [Mon, 27 Mar 2023 11:49:37 +0000 (07:49 -0400)] 
Make cert_data.h and test_cryptoapi/pkcs11.c MSVC compliant

- Do not use non-literal initializers for static objects
- Replace empty initializer {} by {0}

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Co-authored-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230327114937.28246-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26525.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoEnable pkcs11 an dtest_pkcs11 in github actions
Selva Nair [Wed, 22 Mar 2023 22:14:56 +0000 (18:14 -0400)] 
Enable pkcs11 an dtest_pkcs11 in github actions

- Enabled for the Ubuntu 22.04 build (OpenSSL 3) and one of the
  Ubuntu 20.04 builds (OpenSSL 1.1.1).

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230322221456.1660425-3-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26485.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoUnit tests: Test for PKCS#11 using a softhsm2 token
Selva Nair [Wed, 22 Mar 2023 22:14:55 +0000 (18:14 -0400)] 
Unit tests: Test for PKCS#11 using a softhsm2 token

- Load some test certificate/key pairs into a temporary softhsm2 token
  and enumerate available objects through pkcs11-helper interface

- For each object, load it into SSL_CTX and test sign (if using OpenSSL 3)
  or check the certificate and public-key match (if using OpenSSl 1.1.1.).
  The pkcs11-id for each object is specified directly or
  through a mocked management callback to test pkcs11-id-management

Limitations:
  Depends on libsofthsm2.so and p11tool (install softhsm2 and gnutls-bin
  packages). Mbed-TLS/pkcs11-helper combination is not tested.

  If locations of these binaries are not auto-detected or need to be
  overridden, use -DSOFTHSM2_UTIL=<path> -DP11TOOL=<path> to configure.
  Location of SOFTHSM2_MODULE is not auto-detected and defaults to
  /usr/lib/softhsm/libsofthsm2.so. It may be changed by passing
  -DSOFTHSM2_MODULE=/some-path/libsofthsm2.so to configure.
  Also see "configure --help".

  The test is enabled only if --enable-pkcs11 is in use, and SOFTHSM2_UTIL
  & P11TOOL are found in path or manually defined during configuring.

Changes relative to github PR
  - Explicitly disable building the test on Windows: need to port mkstemp,
    mkdtemp, setenv etc., before enabling this on Windows.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230322221456.1660425-2-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26483.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoMove digest_sign_verify out of test_cryptoapi.c
Selva Nair [Wed, 22 Mar 2023 22:14:54 +0000 (18:14 -0400)] 
Move digest_sign_verify out of test_cryptoapi.c

- This function will be reused for testing pkcs11

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230322221456.1660425-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26484.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoGHA: remove Ubuntu 18.04 builds
Frank Lichtenheld [Tue, 28 Mar 2023 10:09:26 +0000 (12:09 +0200)] 
GHA: remove Ubuntu 18.04 builds

Github will stop supporting them on April, 1st.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Matthias Andree <matthias.andree@gmx.de>
Message-Id: <20230328100926.138233-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26541.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoBug-fix: segfault in dco_get_peer_stats()
Selva Nair [Mon, 27 Mar 2023 17:12:36 +0000 (13:12 -0400)] 
Bug-fix: segfault in dco_get_peer_stats()

  We persist peer-stats when restarting, but an early restart
  before open_tun results in a segfault in dco_get_peer_stats().
  To reproduce, trigger a TLS handshake error due to lack of common
  protocols, for example.

  Fix by checking  that tuntap is defined before dereferencing it.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20230327171236.51771-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26530.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoDon't overwrite socket flags when using DCO on Windows
Lev Stipakov [Fri, 24 Mar 2023 12:18:18 +0000 (14:18 +0200)] 
Don't overwrite socket flags when using DCO on Windows

Socket flags can be pushed, in which case they overwrite
existing value. We use socket flags to distingust between
DCO handle and socket on Windows. If server pushes --socket-flags,
we treat DCO handle as socket and everything explodes.

Fix by making link_socket_update_flags() update flags
(like name suggests) instead of overwriting them. Also
do not set TCP_NODELAY on DCO handle on Windows because
it doesn't make sense.

Change-Id: Ia34d73ca49041cb0ce22b84751cdbff57de96048
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230324121818.2358-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26513.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoParse compression options and bail out when compression is disabled
Arne Schwabe [Fri, 24 Mar 2023 12:10:50 +0000 (13:10 +0100)] 
Parse compression options and bail out when compression is disabled

This change keeps the option parsing of compression options even when
compression is disabled. This allows OpenVPN to also refuse/reject
connections that try to use compression when compression is completely
disabled.

Patch v4: fix one missing USE_COMP

Change-Id: I9d7afd8f1d67d2455b4ec6bc12f4dcde80140c4f
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230324121050.1350913-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26512.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAdd 'allow-compression stub-only' internally for DCO
Arne Schwabe [Fri, 24 Mar 2023 10:06:40 +0000 (11:06 +0100)] 
Add 'allow-compression stub-only' internally for DCO

This changes the "no" setting of allow-compression to also refuse framing
if DCO is active.  This is important for our DCO implementations as these
do not implement framing.

This behaviour surfaced when a commercial VPN provider was pushing
"comp-lzo no" to a client with DCO. While we are technically at fault here
for announcing comp-lzo no support by announcing IV_LZO_STUB=1, the
VPN provider continues to push "comp-lzo no" even in absense of that
flag.

As the new default we default to 'allow-compression no' if DCO is
enabled and to 'allow-compression stub' otherwise.

This will now also bail out if the server pushes a compression setting that
we do not support as mismatching compression is almost never a working
connection. In the case of lz4-v2 and lzo-v2 you might have a connection
that works mostly but some packets will be dropped since they compressed
which is not desirable either since it becomes very hard to debug.

Patch v2: bail out if server pushes an unsupported method. Also include this
          bail out logic when OpenVPN is compiled without compression support.

Patch v3: always parse all compression option and move logic to check method
Patch v4: fix for not setting correct default for non-dco

Change-Id: Ibd0c77af24e2214b3055d585dc23a4b06dccd414
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230324100640.1340535-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26509.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoRefuse connection if server pushes an option contradicting allow-compress
Arne Schwabe [Thu, 23 Mar 2023 17:05:59 +0000 (18:05 +0100)] 
Refuse connection if server pushes an option contradicting allow-compress

This removes also the checks in options.c itself as they we now bail out
later and no longer need to ignore them during parsing.

Change-Id: I872c06f402c35112194ba77c3d6aee78e22547cb
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230323170601.1256132-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26503.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoSimplify --compress parsing in options.c
Arne Schwabe [Thu, 23 Mar 2023 17:05:58 +0000 (18:05 +0100)] 
Simplify --compress parsing in options.c

This removes a level of identation and make the "stub" condition
easier to see.

Change-Id: Iae47b191f522625f81eedd3a237b272cb7374d90
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230323170601.1256132-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26501.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco-linux: implement dco_get_peer_stats{, multi} API
Antonio Quartulli [Wed, 22 Mar 2023 19:27:57 +0000 (20:27 +0100)] 
dco-linux: implement dco_get_peer_stats{, multi} API

With this API it is possible to retrieve the stats for a specific peer
or for all peers and then update the userspace counters with the value
reported by DCO.

Change-Id: Ia3990b86b1be7ca844fb1674b39ce0d60528ccff
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230322192757.20767-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26481.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoPrint DCO client stats on SIGUSR2
Lev Stipakov [Wed, 22 Mar 2023 11:32:49 +0000 (13:32 +0200)] 
Print DCO client stats on SIGUSR2

Change-Id: I465febdf7ee5fe573e88255844f718efb60f8e8a
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230322113249.2039-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26471.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco-freebsd: use m->instances[] instead of m->hash
Antonio Quartulli [Thu, 23 Mar 2023 08:03:41 +0000 (09:03 +0100)] 
dco-freebsd: use m->instances[] instead of m->hash

When retrieving the multi_instance of a specific peer,
there is no need to peform a linear search across the
whole m->hash list. We can directly access the needed
object via m->instances[peer-id] in constant time (and
just one line of code).

Adapt the dco-freebsd code to do so.

v4: use "peerid" everywhere as that's what FreeBSD does, change message
text

Cc: Kristof Provost <kp@FreeBSD.org>
Change-Id: I8d8af6f872146604a9710edf443db65df48ac3cb
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Kristof Provost <kp@freebsd.org>
Message-Id: <20230323080341.51624-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/search?l=mid&q=20230323080341.51624-1-gert@greenie.muc.de
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoMake error in setting metric for IPv6 interface non-fatal
Selva Nair [Wed, 22 Mar 2023 15:15:50 +0000 (11:15 -0400)] 
Make error in setting metric for IPv6 interface non-fatal

- Unfortunately there are still users out there who disable IPv6
  on tun/tap/dco interfaces or even system-wide.

Github: fixes OpenVPN/openvpn#294
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230322151550.1596669-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26477.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoFix '--inactive <time> 0' behavior for DCO
Lev Stipakov [Wed, 22 Mar 2023 11:34:08 +0000 (13:34 +0200)] 
Fix '--inactive <time> 0' behavior for DCO

Make sure we exit if <bytes> is 0 (not set) and no traffic
was produced.

According to man page and non-DCO --inactive implementation,
we exit if amount of bytes produced is less than <bytes> specified.
DCO implementation will do off-by-ones, but we consider it as okay
since we don't want to complicate code to handle both bytes=0 and >0
cases.

Change-Id: I4c089e486728a43bfe42596787c00355838311da
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230322113408.2057-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/search?l=mid&q=20230322113408.2057-1-lstipakov@gmail.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodns option: allow up to eight addresses per server
Heiko Hund [Fri, 10 Mar 2023 05:08:12 +0000 (06:08 +0100)] 
dns option: allow up to eight addresses per server

This change allows configuration of more than one address per family
for a DNS server. This way you can specify backup addresses in case a
server is not reachable. During closer inspection of the various DNS
backend in supported operation systems it turned out that our previous
idea to have more than one DNS server applied in order of priority does
not work in most cases. Thus it became important to be able to specify
backup addresses. So instead of doing

  dns server 1 address 1.2.3.4 2001::1
  dns server 2 address 5.6.7.8 2001::2

to specify a backup addresses, this is now done like so:

  dns server 1 address 1.2.3.4 2001::1
  dns server 1 address 5.6.7.8 2001::2

or you can have all the addresses on one line if you like:

  dns server 1 address 1.2.3.4 2001::1 2001::2 5.6.7.8

This also saves some repeated options when (backup) servers share the
same settings like "resolve-domains" compared to the originally intended
way.

The order in which addresses are given is retained for backends that
support this sort of cross address family ordering.

Change-Id: I9bd3d6d05da4e61a5fa05c0e455fc770b1fe186a
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230310050814.67246-1-heiko@ist.eigentlich.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26386.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agomulti: don't call DCO APIs if DCO is disabled
Antonio Quartulli [Tue, 21 Mar 2023 10:28:42 +0000 (11:28 +0100)] 
multi: don't call DCO APIs if DCO is disabled

The agreement with the DCO submodule is that no API should be called if
DCO is actually disabled. For this reason, every invocation must happen
only after having checked that dco_enabled() returns true.

Add missing checks before invoking dco_get_peer_stats_multi()

Reported-by: Lev Stipakov <lev@openvpn.net>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230321102842.10780-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26458.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoImprove description of compat-mode
Arne Schwabe [Mon, 20 Mar 2023 16:55:38 +0000 (17:55 +0100)] 
Improve description of compat-mode

Explicitly say that the version specified is the one of the peer and not
the version we try to emulate.

Patch v2: Improve grammar.
Change-Id: I3bd27a8d34d8cb4896a3b78508b7d16911571543

Change-Id: If4fb45b3426f5e0dbe6c87d5bd05681b9d733827
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230320165538.902965-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26445.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco-linux: remove M_ERRNO flag when printing netlink error message
Antonio Quartulli [Mon, 20 Mar 2023 19:58:20 +0000 (20:58 +0100)] 
dco-linux: remove M_ERRNO flag when printing netlink error message

Netlink has its own error space and reports errors via the return
value of its functions.

For this reason remove the M_ERRNO flag when printing its errors.
At the moment we get something like this:

netlink reports error (-7): Invalid input data or parameter: Interrupted
system call (errno=4)

where the errno=4 (and its human readable representation) is a leftover
from the previous recv() interrupted by a signal and it is totally
unrelated to this netlink failure.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230320195820.6675-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26452.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoImprove error message on short read from socks proxy
Selva Nair [Sat, 18 Mar 2023 14:13:30 +0000 (10:13 -0400)] 
Improve error message on short read from socks proxy

Change-Id: Id00006bf8ea705d02eff2cbfba7d841e1cdb6ae1
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230318141330.1315235-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26437.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoUnit tests: add test for SSL_CTX_use_Cryptoapi_certificate()
Selva Nair [Sat, 18 Mar 2023 14:43:25 +0000 (10:43 -0400)] 
Unit tests: add test for SSL_CTX_use_Cryptoapi_certificate()

- This is the only remaining function in cryptoapi.c that has no
  direct or indirect test.

  This test confirms that an SSL_CTX context gets a certificate and
  private key loaded into it and the public key in the certificate
  matches the private key. As signing with certificate/key pairs
  fetched from the store is independently tested by the 'cryptoapi_sign'
  test, signing is not re-tested here.

  The functions "setup_/teardown_cryptoapi_sign()" are renamed to
  "setup_/teardown_xkey_provider()" to better reflect their purpose.
  These are also reused for the new test.

  While touching this context, also fix a memory leak in
  test_cryptoapi_sign: X509_get_pubkey() -> X509_get0_pubkey()

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230318144325.1316320-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26438.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoOnly update frame calculation if we have a valid link sockets
Arne Schwabe [Wed, 1 Mar 2023 13:44:55 +0000 (14:44 +0100)] 
Only update frame calculation if we have a valid link sockets

Without this, we will caculate a pointer to the linksocket relative to a
null pointer in get_link_socket_info(), which itself does not crash and
the pointer seems not to be accessed later, so we do not get a crash here.

This is still not the correct behaviour and the undefined behaviour
sanitiser from llvm/clang finds this.

Change-Id: I82a20ac72f60f8770ea1b4ab0c8cdea31868abe7
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230301134455.2810114-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26318.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoMake sending plain text control message session aware
Arne Schwabe [Wed, 1 Mar 2023 13:53:53 +0000 (14:53 +0100)] 
Make sending plain text control message session aware

The control messages coming from auth pending should always be on the
session that triggered them (i.e. INITIAL or ACTIVE) and not always on the
active session.  Rework the code path that trigger those messsages from
management and plugin/script to specify the TLS session.

We only support the two TLS sessions that are supposed to be active. TLS
sessions in any lame slot (TM_LAME or KS_LAME) are not considered to be
candidates for sending messages as these slots only serve to keep key
material around.

Unfortunately, this fix requires the management interface to be changed
to allow including the specific session the messages should to go to. As
there are very few users of this interface with auth-pending, I made this
a hard change instead of adding hacky workaround code that is not always
working correctly anyway.

send_control_channel_string() will continue to only use the primary session
and key but the current users of that (push replys and exit notification)
already require the established session to be the active one, so there
no changes needed at the moment.

Github: fixes OpenVPN/openvpn#256

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230301135353.2811069-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26320.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoUse key_state instead of multi for tls_send_payload parameter
Arne Schwabe [Wed, 1 Mar 2023 13:53:52 +0000 (14:53 +0100)] 
Use key_state instead of multi for tls_send_payload parameter

Currently, this function and other parts of OpenVPN assume that
multi->session[TM_ACTIVE].key[KS_PRIMARY] is always the right session
to send control message.

This assumption was only achieve through complicated session moving and
shuffling in our state machine in the past. The old logic basically also
always assumed that control messages are always for fully authenticated
clients. This assumption was never really true (see AUTH_FAILED message)
but has been broken even more by auth-pending. Cleaning up the state machine
transitions in 7dcde87b7a broke this assumption even more.

This change now allows to specify the key_state/TLS session that is used to
send the control message.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230301135353.2811069-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26319.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agousing OpenSSL3 API for EVP PKEY type name reporting
Michael Baentsch [Sun, 19 Mar 2023 07:54:41 +0000 (08:54 +0100)] 
using OpenSSL3 API for EVP PKEY type name reporting

Signed-off-by: Michael Baentsch <info@baentsch.ch>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230319075441.13021-1-info@baentsch.ch>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26439.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoSupport --inactive option for DCO
Lev Stipakov [Wed, 15 Mar 2023 13:38:08 +0000 (15:38 +0200)] 
Support --inactive option for DCO

When DCO is in use, userland doesn't see any traffic
which breaks --inactive option.

Fix by adding inactivity check to inactivity timeout
callback. Get the cumulative tun bytes count (ping packets
are excluded) from DCO and compare it to the previous value
stored in c2.inactivity_bytes. Reset inactivity timer and
update c2.inactivity_bytes if amount of new bytes exceeds
inactivity_minimum_bytes, otherwise terminate session
due to inactivity.

Github: Fixes OpenVPN/openvpn#228

Currently works only on Windows, since we don't yet have
single peer stats implementation for Linux and FreeBSD.

Change-Id: Ib417b965bc4a2c17b51935b43c9627b106716526
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Heiko Hund <heiko@ist.eigentlich.net>
Message-Id: <20230315133808.1550-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26421.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAdd a test for signing with certificates in Windows store
Selva Nair [Wed, 15 Mar 2023 01:35:16 +0000 (21:35 -0400)] 
Add a test for signing with certificates in Windows store

- For each sample certificate/key pair imported into the store,
  load the key into xkey-provider and sign a test message.
  As the key is "provided", signing will use appropriate
  backend (Windows CNG in this case).

  The signature is then verified using OpenSSL.

Change-Id: I520b34ba51e8c6d0247a82edc52bde181ab5a717
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230315013516.1256700-5-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26416.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoRefactor SSL_CTX_use_CryptoAPI_certificate()
Selva Nair [Wed, 15 Mar 2023 01:35:15 +0000 (21:35 -0400)] 
Refactor SSL_CTX_use_CryptoAPI_certificate()

- Loading the certificate and key into the provider is split out of
  setting up the SSL context. This allows testing of signing by
  cryptoapi-provider interface without dependence on SSL context
  or link-time wrapping.

Change-Id: I269b94589636425e1ba9bf953047d238fa830376
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230315013516.1256700-4-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26414.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAdd tests for finding certificates in Windows cert store
Selva Nair [Wed, 15 Mar 2023 01:35:14 +0000 (21:35 -0400)] 
Add tests for finding certificates in Windows cert store

- find_certificate_in_store tested using 'SUBJ:', 'THUMB:'
  and 'ISSUER:' select strings. Uses test certificates
  imported into the store during the import test.

Change-Id: Ib5138465e6228538af592ca98b3d877277355f59
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230315013516.1256700-3-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26415.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoImport some sample certificates into Windows store for testing
Selva Nair [Wed, 15 Mar 2023 01:35:13 +0000 (21:35 -0400)] 
Import some sample certificates into Windows store for testing

- A few sample certificates are defined and imported into
  Windows certificate store (user store).
  This only tests the import process. Use of these certs to test the
  core functionality of 'cryptoapicert' are in following commits.

Change-Id: Ida5fc12c5bad5fde202da0bf0e8cdc71efe548c2
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230315013516.1256700-2-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26417.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoFix memory leaks in HMAC initial packet generation
Arne Schwabe [Wed, 15 Mar 2023 19:55:12 +0000 (20:55 +0100)] 
Fix memory leaks in HMAC initial packet generation

The HMAC leaks are just forgotten frees/deinitialisations.

tls_wrap_control() will sometimes return the original buffer (non
tls-crypt) and sometimes tls_wrap.work, so handling this buffer lifetime
is a bit more complicated.  Instead of further complicating that code
just give our work buffer the same lifetime as the other one inside
tls_wrap.work (put it into per-session gc_arena) as that is also more
consistent.

Second, packet_id_init() allocates a buffer with malloc and not using a
gc_arena, so we need to also manually free it.

Patch v2: add missing deallocations in unit tests of the new workbuf
Patch v3: remove useless allocation of 0 size buffer in
          tls_auth_standalone_init

Found-By: clang with asan
Change-Id: I0cff44f79ee7e3bcf7b5981fc94f469c15f21af3
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230315195512.323070-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoBugfix: Convert ECDSA signature form pkcs11-helper to DER encoded form
Selva Nair [Tue, 14 Mar 2023 12:21:34 +0000 (08:21 -0400)] 
Bugfix: Convert ECDSA signature form pkcs11-helper to DER encoded form

With OpenSSL 3.0 and xkey-provider, we use pkcs11h_certificate_signAny_ex()
which returns EC signature as raw r|s concatenated. But OpenSSL expects
a DER encoded ASN.1 structure.

Do this conversion as done in cryptoapi.c. For code re-use, ecdsa_bin2sig()
is consolidated with sig to DER conversion as ecdsa_bin2der() and
moved to xkey_helper.c

In the past when we used OpenSSL hooks installed by pkcs11-helper,
such a conversion was not required as it was internally handled by
the library.

Reported by: Tom <openvpn@sup-logistik.de>
Also see: https://bugzilla.redhat.com/show_bug.cgi?id=2177834
Tested-by: Florian Apolloner <florian@apolloner.eu>
Change-Id: Ie20cf81edd643ab8ef3c41321353d11fd66c188c
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230314122134.1248576-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26406.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoFix memory leaks in open_tun_dco()
Arne Schwabe [Tue, 14 Mar 2023 14:48:54 +0000 (15:48 +0100)] 
Fix memory leaks in open_tun_dco()

open_tun_dco_generic() already allocates the tt->actual_name string, which
shadows the allocation in the FreeBSD/Linux specific methods.

Found-By: clang with asan
Change-Id: I51f5fcfff4e5f8203fdb9aec0245cfccd17043cc
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230314144854.182110-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26411.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco: print FreeBSD version
Kristof Provost [Thu, 9 Mar 2023 12:23:32 +0000 (13:23 +0100)] 
dco: print FreeBSD version

Implement dco_version_string() for FreeBSD.

Unlike Linux and Windows the DCO driver is built into the operating
system itself, so we log the OS version as a proxy for the DCO version.

Signed-off-by: Kristof Provost <kp@FreeBSD.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230309122332.92490-1-kprovost@netgate.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26367.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco: print version to log if available
Antonio Quartulli [Thu, 9 Mar 2023 13:14:19 +0000 (14:14 +0100)] 
dco: print version to log if available

In order to provide better support in case of troubleshooting issues,
it's important to know what exact DCO version is loaded on the user
system.

Therefore print the DCO version during bootup.

For Windows and FreeBSD we currently implement a placeholder printing 'v0'.
This should be improved with a follow-up patch.

For Linux we directly fetch the module version from /sys and print
something like:

DCO version: 0.1.20230206-15-g580608ec7c59

Change-Id: Ie1f6fa5d12a473d353d84fd119c2430b638e8bcd
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230309131419.29157-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26370.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco: don't use NetLink to exchange control packets
Antonio Quartulli [Thu, 9 Mar 2023 21:03:44 +0000 (22:03 +0100)] 
dco: don't use NetLink to exchange control packets

Using NetLink for control messages did not work out as it did lead to
kernel side buffer congestion during heavy client activity.

With this patch DCO will redirect control packets directly to the
transport socket without altering them, so that userspace can
happily process them as usual.

NOTE: this is an API breaking change.  Up to this commit, the userland
requests a kernel module called "ovpn-dco" which does control messages
via netlink.  From this commit on, OpenVPN requests a kernel module named
"ovpn-dco-v2" which brings the kernel change corresponding to this commit.

If the system only has "the wrong module" available (either way), OpenVPN
will log

   ... Kernel support for ovpn-dco missing, disabling data channel offload.

and proceed without kernel support.

Change-Id: Ia1297c3ae9a28b188ed21ad21ae96fff3d02ee4d
[lev@openvpn.net: ensure win_dco flag is still exposed]
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230309210344.5763-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26384.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agotests/unit_tests: Fix 'make distcheck' with subdir-objects enabled
Frank Lichtenheld [Wed, 8 Mar 2023 15:07:04 +0000 (16:07 +0100)] 
tests/unit_tests: Fix 'make distcheck' with subdir-objects enabled

Commit 7f72abcf8a56bb35a510a3409e03a4e2aaba50da enabled subdir-objects
when using automake 1.16+.

There is an issue with the handling of .deps directories with this option.
While automake 1.16 fixed subdir-objects to work at all when _SOURCES
contains "unexpanded references" and it did fix subdir-objects to work
with out-of-tree build for "source files specified with an explicit
'$(srcdir)'" those fixes are not transitive. "unexpanded references"
still break out-of-tree builds when enforcing a read-only source dir
like 'make distcheck' does. When using *explicit* references to
srcdir and top_srcdir it works correctly.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20230308150704.128797-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26352.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoEnsure n = 2 is set in key2 struct in tls_crypt_v2_unwrap_client_key
Arne Schwabe [Thu, 9 Mar 2023 12:00:31 +0000 (13:00 +0100)] 
Ensure n = 2 is set in key2 struct in tls_crypt_v2_unwrap_client_key

The ASSERT in xor_key2 assumes that all methods that load a key2 struct
correctly set n=2. However, tls_crypt_v2_unwrap_client_key loads a key
without setting n = 2, triggering the assert.

Github: Closes and reported in OpenVPN/openvpn#272

Change-Id: Iaeb163d83b95818e0b26faf9d25e7737dc8ecb23
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20230309120031.3780130-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26363.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoSet netlink socket to be non-blocking
Arne Schwabe [Wed, 8 Mar 2023 15:19:45 +0000 (16:19 +0100)] 
Set netlink socket to be non-blocking

Even though we use select/poll to explicitly query when the netlink
socket is ready for read, sometimes we end up reading from the socket
when it is not ready to read and then the process hangs for several
seconds (20-30s). Avoid this situation by setting the socket to be
non-blocking, so we get a status in this case that allows us to continue.

Change-Id: I35447c23a9350176007df5455bf9451021e9856d
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20230308151945.3670151-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26353.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAvoid warning about missing braces when initialising key struct
Antonio Quartulli [Wed, 8 Mar 2023 13:37:43 +0000 (14:37 +0100)] 
Avoid warning about missing braces when initialising key struct

This avoids the warning from gcc about initialising the key2 struct.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230308133743.5059-1-a@unstable.cc>
URL: https://www.mail-archive.com/search?l=mid&q=20230308133743.5059-1-a@unstable.cc
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoFreeBSD 12.x workaround for IPv6 ifconfig is needed on 12.4 as well
Gert Doering [Mon, 6 Mar 2023 08:07:44 +0000 (09:07 +0100)] 
FreeBSD 12.x workaround for IPv6 ifconfig is needed on 12.4 as well

Commit 16d7f2cd4d90 tried to remove an FreeBSD 12.x ifconfig inet6
workaround based on the understanding that the upstream fix for
bug 248172 went into 12.4, but that was a misread of the code - 12.4
needs the workaround as well, fixed in 13.0.

Also extend comment to point to /etc/network.subr, which is the real
source of the problematic code

        if checkyesno ipv6_activate_all_interfaces; then
                _ipv6_opts="-ifdisabled"
        elif [ "$1" != "lo0" ]; then                   <<<<
                _ipv6_opts="ifdisabled"                <<<<
        fi

Trac: 1226

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230306080744.66069-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26335.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoDynamic tls-crypt for secure soft_reset/session renegotiation
Arne Schwabe [Tue, 7 Mar 2023 15:02:33 +0000 (16:02 +0100)] 
Dynamic tls-crypt for secure soft_reset/session renegotiation

Currently we have only one slot for renegotiation of the session/keys.
If a replayed/faked packet is inserted by a malicous attacker, the
legimate peer cannot renegotiate anymore.

This commit introduces dynamic tls-crypt. When both peer support this
feature, both peer create a dynamic tls-crypt key using TLS EKM (export
key material) and will enforce using that key and tls-crypt for all
renegotiations. This also add an additional protection layer for
renegotiations to be taken over by an illegimate client, binding the
renegotiations tightly to the original session. Especially when 2FA,
webauth or similar authentication is used, many third party setup ignore
the need to secure renegotiation with an auth-token.

Since one of tls-crypt/tls-crypt-v2 purposes is to provide poor man's post
quantum crypto guarantees, we have to ensure that the dynamic key tls-crypt
key that replace the original tls-crypt key is as strong as the orginal key
to avoid problems if there is a weak RNG or TLS EKM produces weak keys. We
ensure this but XORing the original key with the key from TLS EKM. If
tls-crypt/tls-cryptv2 is not active, we use just the key generated by
TLS EKM. We also do not use hashing or anything else on the original key
before XOR to avoid any potential of a structure in the key or something
else that might weaken post-quantum use cases.

OpenVPN 2.x reserves the TM_ACTIVE session for renegotiations. When a
SOFT_RESET_V1 packet is received, the active TLS session is moved from
KS_PRIMARY to KS_SECONDARY. Here an attacker could theorectically send a
faked/replayed SOFT_RESET_V1 and first packet containing the TLS client
hello. If this happens, the session is blocked until the TLS
renegotiation attempt times out, blocking the legimitate client.

Using a dynamic tls-crypt key here blocks any SOFT_RESET_V1 (and following
packets) as replay and fake packets will not have a matching
authentication/encryption and will be discarded.

HARD_RESET packets that are from a reconnecting peer are instead put in the
TM_UNTRUSTED/KS_PRIMARY slot until they are sufficiently verified, so the
dynamic tls-crypt key is not used here.  Replay/fake packets also do not
block the legimitate client.

This commit delays the purging of the original tls-crypt key data from
directly after passing it to crypto library to tls_wrap_free. We do this
to allow us mixing the new exported key with the original key.
To be able to generate the dynamic tls-cryptn key, we need the original
key, so deleting the key is not an option if we need it later again to
generate another key. Even when the client does not support secure
renegotiation, deleting the key is not an option since when the
reconnecting client or (especially in p2p mode with float) another client
does the reconnect, we might need to generate a dynamic tls-crypt key
again. Delaying the deletion of the key has also little effect as the
key is still present in the OpenSSL/mbed TLS structures in the tls_wrap
structure, so only the number of times the keys is in memory would be
reduced.

Patch v2: fix spellings of reneg and renegotiations.
Patch v3: expand comment to original_tlscrypt_keydata and commit message,
          add Changes.rst
Patch v4: improve commit message, Changes.rst
Patch v5: fix spelling/grammar mistakes. Add more comments.
Patch v6: consistently calld this feature dynamic tls-crypt crypt. Note
          this changes the export label and makes it incompatible with
          previous patches.
Patch v7: also xor tls-auth key data into the dynamic tls-crypt key like
          tls-crypt key data
Patch v8: Avoid triggering ASSERT added in v7 by properly setting keys.n = 2
          when loading tls crypt v2 client keys. Add dyn-tls-crypt to
          protocol options printout.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Heiko Hund <heiko@ist.eigentlich.net>
Message-Id: <20230307150233.3551436-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26341.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoDo not save pointer to 'struct passwd' returned by getpwnam etc.
Selva Nair [Mon, 6 Mar 2023 05:33:45 +0000 (00:33 -0500)] 
Do not save pointer to 'struct passwd' returned by getpwnam etc.

- This pointer is to a static area which can change on further
  calls to getpwnam, getpwuid etc.
  Same with struct group returned by getgrnam.

  As the only field later referred to is uid or gid, fix
  by saving them instead.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230306053346.796992-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26332.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoReduce initialisation spam from verb <= 3 and print summary instead
Arne Schwabe [Tue, 14 Feb 2023 11:20:44 +0000 (12:20 +0100)] 
Reduce initialisation spam from verb <= 3 and print summary instead

The messages about cipher initialisation are currently very noisy,
especially if tls-auth/tls-crypt is in use.

Typically messages like this is display for AES-256-CBC with SHA256:

   Outgoing Data Channel: Cipher 'AES-256-CBC' initialized with 256 bit key
   Outgoing Data Channel: Using 256 bit message hash 'SHA256' for HMAC authentication
   Incoming Data Channel: Cipher 'AES-256-CBC' initialized with 256 bit key
   Incoming Data Channel: Using 256 bit message hash 'SHA256' for HMAC authentication

in addition to the tls-crypt/tls-auth messages that has the amount of
messages.

These message are not that helpful. The only meaningful information is
better suited in compat messages. This commit moves the spammy messages
to verb 4 and consistently prints out the cipher/auth used in the data
channel instead on verb 2:

   Data Channel: cipher 'AES-256-CBC' auth 'SHA256'

This patches also summarises other aspects of the imported options for VPN
connection and prints them (even if not coming from pulled options):

    Data Channel: cipher 'AES-256-GCM'
    Timers: ping 8, ping-restart 40
    Protocol options: explicit-exit-notify 1, protocol-flags tls-ekm

And move the OPTIONS IMPORT: xx modified that are included in the new
messages to D_PUSH_DEBUG (verb 7) since they do not add any useful
information anymore.

Patch v2: also compile with compression disabled

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230214112044.1021962-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26249.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco: define OVPN_DEL_PEER_REASON_TRANSPORT_DISCONNECT on FreeBSD
Kristof Provost [Fri, 3 Mar 2023 11:05:11 +0000 (12:05 +0100)] 
dco: define OVPN_DEL_PEER_REASON_TRANSPORT_DISCONNECT on FreeBSD

FreeBSD's if_ovpn will never emit this as a peer deletion reason
(because it doesn't support TCP), but this allows us to align the
defines between Linux and FreeBSD, and remove a Linux-specific case from
process_incoming_del_peer().

Signed-off-by: Kristof Provost <kprovost@netgate.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20230303110511.9569-1-kprovost@netgate.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26324.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoconfigure: improve FreeBSD DCO check
Kristof Provost [Wed, 1 Mar 2023 09:18:48 +0000 (10:18 +0100)] 
configure: improve FreeBSD DCO check

The libnv check doesn't work as expected on FreeBSD 14.x, because
FreeBSD has namespaced libnv to avoid conflicts with libnvpair.
This means that the naive check generated by AC_CHECK_LIB() fails to
detect libnv even though it's present.

Instead check for the if_ovpn.h header. This is a more accurate check
anyway, as libnv is present on FreeBSD versions prior to 14 (which do
not support DCO).

Signed-off-by: Kristof Provost <kprovost@netgate.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230301091848.80760-1-kprovost@netgate.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26314.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agooptions.c: enforce a minimal fragment size
Kristof Provost [Wed, 1 Mar 2023 09:18:51 +0000 (10:18 +0100)] 
options.c: enforce a minimal fragment size

Very low values for 'fragment' can result in a division by zero in
optimal_fragment_size() (because it rounds max_frag_size down with
FRAG_SIZE_ROUND_MASK).

Enforce a minimal fragment size of 68 bytes, based on RFC 791 ("Every
internet module must be able to forward a datagram of 68 octets without
further fragmentation.")

Signed-off-by: Kristof Provost <kprovost@netgate.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230301091851.82243-1-kprovost@netgate.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26313.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoUse proper print format/casting when converting msg_channel handle
Arne Schwabe [Tue, 14 Feb 2023 13:43:23 +0000 (14:43 +0100)] 
Use proper print format/casting when converting msg_channel handle

The current casting triggers a warning on 32bit:

    init.c:1842:66: error: cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]

Use the proper printf format specifier for printing a pointer avoiding
the cast alltogether.

In options.c use a cast to intptr_t before converting to a handle to
avoid having to ifdef atoll/atol for 32/64 bit.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230214134323.1033590-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26255.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAvoid management log loop with verb >= 6
Lev Stipakov [Fri, 17 Feb 2023 12:21:55 +0000 (14:21 +0200)] 
Avoid management log loop with verb >= 6

This log message is printed within check_tls(),
which is called by pre_select(), which is called
on every iteration of event loop.

When management is attached (and doesn't use own event loop),
this message sets management state to "wait write",
which arms event loop. When on the next iteration iowait
returns with "management write event is set", we call
pre_select() and print that message again, causing the loop.

Fix by simply removing this log message.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20230217122156.541-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26284.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoUpdate issue templates
Antonio Quartulli [Sun, 26 Feb 2023 21:34:20 +0000 (22:34 +0100)] 
Update issue templates

With this change we extend the text exposed to people opening a bug in
the OpenVPN project.

Hopefully they will read and immediately understand that GH is not the
right place to report ossues about commercial products.

Change-Id: Idd039612698a6b08f9544450885d1a5f77fd95c6
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230226213420.21201-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26305.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoconfigure: fix formatting of --disable-lz4 and --enable-comp-stub
Frank Lichtenheld [Mon, 6 Feb 2023 13:08:46 +0000 (14:08 +0100)] 
configure: fix formatting of --disable-lz4 and --enable-comp-stub

Make consistent with the other options.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230206130846.63415-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26156.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoWindows: fix signedness errors with recv/send
Frank Lichtenheld [Fri, 3 Feb 2023 19:14:40 +0000 (20:14 +0100)] 
Windows: fix signedness errors with recv/send

On Linux those functions actually take void pointer,
so no behavior change there. On Windows, we avoid
warnings about unsigned char vs char.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230203191440.136050-6-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26144.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAdd a unit test for functions in cryptoapi.c
Selva Nair [Tue, 14 Feb 2023 20:08:04 +0000 (15:08 -0500)] 
Add a unit test for functions in cryptoapi.c

- Though named cryptoapi_testdriver, right now this only tests
  parsing of thumbprint specified as a selector for --cryptioapicert
  option. More tests coming..

v2: a line that belongs here was mistakenly included in the previous
commit. Corrected.
v3: add to list of tests run in github actions
v4: - correct comment above invalid strings (copy paste error)
    - make invalid strings differ from correct value only in the
      explicitly introduced invalid characters/separators (one had
      two distinct errors which is not a robust test).

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230214200804.600405-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26268.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAdd logging for windows driver selection process
Lev Stipakov [Thu, 16 Feb 2023 16:01:29 +0000 (18:01 +0200)] 
Add logging for windows driver selection process

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230216160129.994-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26281.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoconfigure: enable DCO by default on FreeBSD/Linux
Frank Lichtenheld [Wed, 15 Feb 2023 16:26:54 +0000 (17:26 +0100)] 
configure: enable DCO by default on FreeBSD/Linux

Automatically disabled when
- iproute2 is enabled
  (Don't want to force people specifying --disable-dco explicitely)
- libnv is missing on FreeBSD
  (FreeBSD version too old anyway)

Will still error out if libnl-genl is missing on Linux to
make people aware of new dependency.

v2: error out when libnl-genl is missing as discussed with ordex on
    IRC.
v3:
 - improvements to the messages, suggested by Selva
 - further improvements to the default specification, trying to make it clear
 - if enabling iproute2, do not test for libnl-genl
v4: add updates for GHA
v5:
 - v4 was missing the changes of v3. v5 combines the changes from v3 and v4
 - fix build failure GHA/ubuntu1804/mbedtls
 - fix build failure GHA/ubuntu2204/libressl

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20230215162654.52137-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26272.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoDisable DCO if proxy is set via management
Lev Stipakov [Mon, 20 Feb 2023 09:06:01 +0000 (11:06 +0200)] 
Disable DCO if proxy is set via management

DCO doesn't support proxy and we already disable DCO
is proxy is set in profile.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20230220090601.983-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26287.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoExit if a proper message instead of segfault on Android without management
Arne Schwabe [Mon, 20 Feb 2023 13:14:24 +0000 (14:14 +0100)] 
Exit if a proper message instead of segfault on Android without management

The Android implementation is relying on the management interface to be
always available. Trying to run the Android binary without the mangament
interface outside the app leads to a segfault. Exit with a FATAL error
instead.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230220131424.1749736-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26288.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoOption --cryptoapicert: support issuer name as a selector
Selva Nair [Sat, 28 Jan 2023 22:34:18 +0000 (17:34 -0500)] 
Option --cryptoapicert: support issuer name as a selector

- Certificate selection string can now specify a partial
  issuer name string as "--cryptoapicert ISSUER:<string>" where
  <string> is matched as a substring of the issuer (CA) name in
  the certificate.

  Partial case-insensitive matching against the "issuer name" is
  used. Here "issuer name" is a text representation of the RDN's
  separated by commas.

  E.g., "CA, Ontario, Toronto, Acme Inc., IT, Acme Root CA".

  See MSDN docs on CertFindCertificateInStore() with CERT_FIND_ISSUER_STR
  as "FindType" for more details.

  As the order of RDN's is not well-defined[*] and type names like "OU"
  or "CN" are not included, its best to match against a single attribute
  like the CN of the issuer:

  E.g., --cryptoapicert "ISSUER:Acme Root"

[*] Windows appears to order RDN's in the reverse order to which
its written in the certificate but do not rely on this.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230128223421.2207802-2-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26092.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agocryptoapi.c: simplify parsing of thumbprint hex string
Selva Nair [Sat, 4 Feb 2023 00:43:22 +0000 (19:43 -0500)] 
cryptoapi.c: simplify parsing of thumbprint hex string

v2: Moved the "parse_hexstring" chunk to a function for clarity
and to permit unit-testing.

A test is submitted as a follow up patch.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230204004322.250210-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26146.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agocryptoapi.c: remove pre OpenSSL-3.01 support
Selva Nair [Wed, 1 Feb 2023 23:03:40 +0000 (18:03 -0500)] 
cryptoapi.c: remove pre OpenSSL-3.01 support

- Require xkey-provider (thus OpenSSL 3.01+) for --cryptoapicert

Note:
  Ideally we should also make ENABLE_CRYPTOAPI conditional
  on HAVE_XKEY_PROVIDER but that looks hard unless we can agree
  to move HAVE_XKEY_PROVIDER to configure/config.h.

v2: use "binary" instead of "version" in the error message

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230201230340.2268781-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26131.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agocyryptapi.c: log the selected certificate's name
Selva Nair [Sat, 28 Jan 2023 22:34:19 +0000 (17:34 -0500)] 
cyryptapi.c: log the selected certificate's name

- With various ways of specifying the selector-string to the
  "--cryptoapicert" option, its not immediately obvious
  which certificate gets selected from the store. Log it.

  The "name" logged is a friendly name (if present), or a
  representative element of the subject (usually the common-name).

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230128223421.2207802-3-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26093.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoRevise the cipher negotiation info about OpenVPN3 in the man page
Arne Schwabe [Fri, 10 Feb 2023 14:27:10 +0000 (15:27 +0100)] 
Revise the cipher negotiation info about OpenVPN3 in the man page

Newer OpenVPN 3 core versions now allow limited configuration of ciphers:

    // Allow usage of legacy (cipher) algorithm that are no longer
    // considered safe
    // This includes BF-CBC, single DES and RC2 private key encryption.
    // With OpenSSL 3.0 this also instructs OpenSSL to load the legacy
    // provider.
    bool enableLegacyAlgorithms = false;

    // By default modern OpenVPN version (OpenVPN 2.6 and OpenVPN core
    // 3.7) will only allow
    // preferred algorithms (AES-GCM, Chacha20-Poly1305) that also work
    // with the newer DCO
    // implementations. If this is enabled, we fall back to allowing all
    // algorithms (if these are
    // supported by the crypto library)
    bool enableNonPreferredDCAlgorithms = false;

Adjust the man page section accordingly but only really mention the AEAD
ciphers to be always present and that they should be included in the
data-ciphers option.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230210142712.572303-7-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26226.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAdd building unit tests with mingw to github actions
Arne Schwabe [Thu, 9 Feb 2023 16:37:05 +0000 (17:37 +0100)] 
Add building unit tests with mingw to github actions

This runs each test in its own action since order of stderr and stdout
is seemingly random in github action Windows output and this way at least
tests outputs are grouped by test

Patch v2: use -static-libgcc to avoid comping gcc runtime libraries.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20230209163705.466173-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26204.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoImprove format specifier for socket handle in Windows
Lev Stipakov [Fri, 10 Feb 2023 13:31:59 +0000 (15:31 +0200)] 
Improve format specifier for socket handle in Windows

Socket is a handle on Windows, which is usually logged in hex.
Also an interesting value is INVALID_SOCKET, which is ~0.

PRIuPTR prints decimals, and for INVALID_SOCKET it prints something like

  2023-02-10 14:45:21 us=906000 write to TUN/TAP : Jrjestelmkutsulle
annettu data-alue on liian pieni.   (fd=18446744073709551615,code=122)

PRIxPTR prints hex, and INVALID_SOCKET looks a bit nicer:

  2023-02-10 15:17:11 us=828000 write to TUN/TAP : Jrjestelmkutsulle
annettu data-alue on liian pieni.   (fd=ffffffffffffffff,code=122)

Reported-by: Selva Nair <selva.nair@gmail.com>
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20230210133159.1336-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26220.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoUpdate the last sections in the man page to a be a bit less outdated
Arne Schwabe [Fri, 10 Feb 2023 14:27:09 +0000 (15:27 +0100)] 
Update the last sections in the man page to a be a bit less outdated

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230210142712.572303-6-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26224.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoCombine extra_tun/frame parameter of frame_calculate_payload_overhead
Arne Schwabe [Fri, 10 Feb 2023 14:27:06 +0000 (15:27 +0100)] 
Combine extra_tun/frame parameter of frame_calculate_payload_overhead

Instead of passing a value and a bool just pass the value and 0 if
the caller does not want the value to be added. This also allows
the function to be used by a function without a frame struct.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230210142712.572303-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26223.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco-win: use proper calling convention on x86
Lev Stipakov [Tue, 31 Jan 2023 12:54:48 +0000 (14:54 +0200)] 
dco-win: use proper calling convention on x86

WinAPI uses __stdcall calling convention on x86. Wrong
calling convention causes UB, which in this case breaks
dco-win functionality.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230131125448.1913-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26113.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoBuild unit tests in mingw Windows build
Selva Nair [Wed, 8 Feb 2023 00:59:25 +0000 (19:59 -0500)] 
Build unit tests in mingw Windows build

- Minor changes to the build system to include some
  dependencies for Windows build

- test_tls_crypt not built as it will pull in win32.c and
  its dependencies

- If cross-compiling, "make check" will only build the tests but not
  run any. Copy to Windows and run manually. Executables are in
  <buid-dir>/tests/unit_tests/openvpn/.libs/ and these depend on
  cmocka.dll in addition to openssl libs that some tests link to.

  Building with mingw on Windows should run the tests (untested).

v2: networking_testdriver was mistakenly enabled to run, while
originally it was only set to build. Corrected.

v3: exclude check_engine_keys.sh when cross-compiling
As suggested by Arne Schwabe <arne@rfc2549.org>

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230208005925.393200-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26188.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAdd missing stdint.h includes in unit tests files
Arne Schwabe [Wed, 8 Feb 2023 00:18:18 +0000 (01:18 +0100)] 
Add missing stdint.h includes in unit tests files

My mingw compiler/headers (mingw-w64 10.0.0 on macOS) seem to be more
pendantic than the one that comes with Ubuntu 22.04 (github actions) or
any of the other platforms including msvc/normal windows header.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20230208001819.244694-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26182.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoGet rid of unused 'bool tuntap_buffer' arguments.
Gert Doering [Wed, 1 Feb 2023 14:15:18 +0000 (14:15 +0000)] 
Get rid of unused 'bool tuntap_buffer' arguments.

overlapped_io_init() has a "bool tuntap_buffer" argument which is only
passed onwards to alloc_buf_sock_tun(), which does nothing with it.

Remove from both functions.

v2:
  move alloc_buf_sock_tun() to win32.c

v3:
  leave alloc_buf_sock_tun() where it is, and fix non-WIN32 call from
socket.c

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230130161730.110021-1-gert@greenie.muc.de>
URL:
https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26099.h
tml
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit bdc842d72e92995261bac3579120c94f93e4064a)
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230201141518.119157-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26122.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoConditionally add subdir-objects option to automake
Selva Nair [Sat, 4 Feb 2023 00:45:10 +0000 (19:45 -0500)] 
Conditionally add subdir-objects option to automake

- Eliminates repeated warnings such as
  warning: source file '$(openvpn_srcdir)/env_set.c' is in a subdirectory,
  but option 'subdir-objects' is disabled
- Enabled only for automake >= 1.16 as older versions have a buggy
  implementation of this option

Main side effect of this option is that object files like
openvpnserv-blockdns.o are now created in src/openvpn where block-dns.c
resides instead of in src/openvpnserv.

Same for object files for sources from $(openvpn_srcdir) compiled
into test executables.

See also past discussion on this topic:

https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg00013.html

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230204004512.250271-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26147.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAllow certain DHCP options to be used without DHCP server
Lev Stipakov [Tue, 7 Feb 2023 14:54:16 +0000 (16:54 +0200)] 
Allow certain DHCP options to be used without DHCP server

Followin DHCP options:

  DOMAIN, ADAPTER_DOMAIN_SUFFIX, DNS, WINS

don't require DHCP server in order to be used.

This change allows those options to be used with dco and wintun
drivers. If an option specified which requires DHCP server and
tap-windows6 driver is not used, print a clear error message
instead of obscure reference to --ip-win32.

Reported-by: Marek Zarychta
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20230207145416.1415-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26169.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoFix LibreSSL not building in Github Actions
Arne Schwabe [Thu, 9 Feb 2023 16:31:15 +0000 (17:31 +0100)] 
Fix LibreSSL not building in Github Actions

During the build of LibreSSL portable it pulls in a branch from OpenBSD
upstream. Unfortunately they use master there instead of a fixed branch.
So we work around this issue.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230209163115.465548-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/search?l=mid&q=20230209163115.465548-1-arne@rfc2549.org
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoWindows: fix unused variable in win32_get_arch
Frank Lichtenheld [Fri, 3 Feb 2023 19:14:39 +0000 (20:14 +0100)] 
Windows: fix unused variable in win32_get_arch

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230203191440.136050-5-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26141.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoWindows: fix wrong printf format in x_check_status
Frank Lichtenheld [Tue, 7 Feb 2023 13:43:33 +0000 (14:43 +0100)] 
Windows: fix wrong printf format in x_check_status

Relevant defines/typedefs:
typedef UINT_PTR        SOCKET;
if defined(_WIN64)
 typedef unsigned __int64 UINT_PTR;
else
 typedef unsigned int UINT_PTR;
endif
ifdef _WIN64
 define PRIuPTR  PRIu64
else
 define PRIuPTR  PRIu32
endif

Remove duplicated include of inttypes.h

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230207134333.52221-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26166.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoWindows: fix unused variables in delete_route_ipv6
Frank Lichtenheld [Fri, 3 Feb 2023 19:14:37 +0000 (20:14 +0100)] 
Windows: fix unused variables in delete_route_ipv6

At this point it might be easier to create a
dedicated function for Windows...

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230203191440.136050-3-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26140.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoWindows: fix unused function setenv_foreign_option
Frank Lichtenheld [Fri, 3 Feb 2023 19:14:36 +0000 (20:14 +0100)] 
Windows: fix unused function setenv_foreign_option

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230203191440.136050-2-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26145.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoblock-dns using iservice: fix a potential double free
Selva Nair [Wed, 1 Feb 2023 17:07:35 +0000 (12:07 -0500)] 
block-dns using iservice: fix a potential double free

- An item added to undo-list was not removed on error, causing
  attempt to free again in Undo().
  Also fix a memory leak possibility in the same context.

Github: fixes OpenVPN/openvpn#232

v2: Split add and delete functions and reuse the delete
function for cleanup.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230201170735.2266851-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26130.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoChanges.rst: document removal of --keysize
Frank Lichtenheld [Wed, 1 Feb 2023 13:52:21 +0000 (14:52 +0100)] 
Changes.rst: document removal of --keysize

When reviweing OpenVPN/openvpn#231 I noticed this was
missing from Changes.rst.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230201135221.36135-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26121.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAdd printing USAN stack trace on github actions
Arne Schwabe [Mon, 30 Jan 2023 17:29:35 +0000 (18:29 +0100)] 
Add printing USAN stack trace on github actions

This allows identifying the source of undefined behaviour more easily
from the github action logs.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230130172936.3444840-4-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26102.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoUpdate LibreSSL to 3.7.0 in Github actions
Arne Schwabe [Mon, 30 Jan 2023 17:29:34 +0000 (18:29 +0100)] 
Update LibreSSL to 3.7.0 in Github actions

The version 3.5.3 triggers undefined behaviour with the usan sanatizer.
Updating LibreSSSL to 3.7.0 does unfortunately does not fix the issue but
at least we are now using a current version.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230130172936.3444840-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26105.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoFix unaligned access in auth-token
Arne Schwabe [Mon, 30 Jan 2023 17:29:32 +0000 (18:29 +0100)] 
Fix unaligned access in auth-token

The undefined behaviour USAN clang checker found this. The optimiser
of clang/gcc will optimise the memcpy away in the auth_token case and
output excactly the same assembly on amd64/arm64 but it is still better
to not rely on undefined behaviour.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230130172936.3444840-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26103.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agomake dist: Ship ovpn_dco_freebsd.h, too
Matthias Andree [Fri, 27 Jan 2023 20:32:08 +0000 (21:32 +0100)] 
make dist: Ship ovpn_dco_freebsd.h, too

This file was missing from src/openvpn/Makefile.am.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230127203208.305638-1-matthias.andree@gmx.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26085.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco_linux: update license for ovpn_dco_linux.h
Antonio Quartulli [Wed, 25 Jan 2023 09:53:21 +0000 (10:53 +0100)] 
dco_linux: update license for ovpn_dco_linux.h

The linux userspace API header has acquired the MIT license (check the
ovpn-dco repository for the related change), therefore we simply bring
this change in our local copy to ensure compliancy.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230125095321.23063-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26077.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoopenvpnmsica: fix adapters discovery logic for DCO
Lev Stipakov [Tue, 24 Jan 2023 14:23:16 +0000 (16:23 +0200)] 
openvpnmsica: fix adapters discovery logic for DCO

Custom action "FindSystemInfo" finds adapters with certain hwid and
assigns found adapters' guids to a certain property. Later another custom
action "EvaluateTUNTAPAdapters" schedules adapter creation if the
abovementioned property is not set - which means no adapters exist
with given hwid.

I think this logic is needed to prevent duplicate adapter creation
if adapter was renamed and then new version is installed.

As one can see, there is a typo in property name ("OVPNDCOAPTERS"). As
a result of this typo, installer will always try to create DCO adapter
no matter if there are existing adapters. It however won't do anything
if adapter with the name "OpenVPN Data Channel Offload" already exists,
this is handled in schedule_adapter_create() function.

Because of that typo, following scenario works fine:

 1) Upcoming release of OpenVPN Connect is installed, which creates
adapter named "OpenVPN Connect DCO Adapter"

 2) OpenVPN-GUI is installed. Because of typo, it ignores adapter created
by Connect and creates own "OpenVPN Data Channel Offload" adapter

 3) OpenVPN Connect is uninstalled and it removes
"OpenVPN Connect DCO Adapter".

 4) OpenVPN-GUI still has its "OpenVPN Data Channel Offload" adapter

If we just fix a typo, OpenVPN-GUI won't create a adapter on step 2 and
after Connect removal on step 3 there won't be DCO adapters anymore
for OpenVPN-GUI to use.

The ultimate solution to this would be moving adapter creation to MSM,
a shared component which adds/removes the DCO driver. However this change
is not trivial and requires a lot of work. For the time being we apply
this band-aid by excluding Connect-created adapters from enumerations in
"FindSystemInfo" custom action. This makes sure that OpenVPN-GUI won't
rely on adapter created by Connnect (which is deleted on Connect uninstall)
and ensures that additional DCO adapters won't be created on upgrade
if user decides to rename adapter.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20230124142316.441-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26072.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>