From: "stipa (Code Review)" Date: Mon, 16 Oct 2023 12:08:26 +0000 In-Reply-To: References: Reply-To: lstipakov@...277..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <7600425edad23da4e2fdab976af9e637919cd164-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="K7AUZ8yJrKM="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[release/2.6]: dco: warn if DATA_V1 packets are sent to userspace List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --K7AUZ8yJrKM= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos, stipa. Hello flichtenheld, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/368?usp=3Demail to look at the new patch set (#2). The following approvals got outdated and were removed: Code-Review+2 by flichtenheld, Code-Review+2 by plaisthos The change is no longer submittable: Code-Review and checks~ChecksSubmitRul= e are unsatisfied now. Change subject: dco: warn if DATA_V1 packets are sent to userspace ...................................................................... dco: warn if DATA_V1 packets are sent to userspace Servers 2.4.0 - 2.4.4 support peer-id and AEAD ciphers, but only send DATA_V1 packets. With DCO enabled on the client, connection is established but not working. This is because DCO driver(s) are unable to handle DATA_V1 packets and forwards them to userspace, where they silently disappear since crypto context is in DCO and not in userspace. Starting from 2.4.5 server sends DATA_V2 so problem doesn't happen. We cannot switch to non-DCO on the fly, so we log this and advice user to upgrade the server to 2.4.5 or newer. This fixes https://github.com/OpenVPN/openvpn/issues/422 Change-Id: I8cb2cb083e3cdadf187b7874979d79af3974e759 Signed-off-by: Lev Stipakov --- M src/openvpn/forward.c 1 file changed, 20 insertions(+), 3 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/68/368/2 diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index d8ad0d1..40f21bc 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -1047,6 +1047,24 @@ if (c->c2.tls_multi) { + uint8_t opcode =3D *BPTR(&c->c2.buf) >> P_OPCODE_SHIFT; + + /* + * If DCO is enabled, the kernel drivers require that the + * other end only sends P_DATA_V2 packets. V1 are unknown + * to kernel and passed to userland, but we cannot handle them + * either because crypto context is missing - so drop the pack= et. + * + * This can only happen with particular old (2.4.0-2.4.4) serv= ers. + */ + if ((opcode =3D=3D P_DATA_V1) && dco_enabled(&c->options)) + { + msg(D_LINK_ERRORS, + "Data Channel Offload doesn't support DATA_V1 packets.= " + "Upgrade your server to 2.4.5 or newer."); + c->c2.buf.len =3D 0; + } + /* * If tls_pre_decrypt returns true, it means the incoming * packet was a good TLS control channel packet. If so, TLS c= ode @@ -1057,9 +1075,8 @@ * will load crypto_options with the correct encryption key * and return false. */ - uint8_t opcode =3D *BPTR(&c->c2.buf) >> P_OPCODE_SHIFT; - if (tls_pre_decrypt(c->c2.tls_multi, &c->c2.from, &c->c2.buf, = &co, - floated, &ad_start)) + if (tls_pre_decrypt(c->c2.tls_multi, &c->c2.from, &c->c2.buf, + &co, floated, &ad_start)) { /* Restore pre-NCP frame parameters */ if (is_hard_reset_method2(opcode)) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/368?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: release/2.6 Gerrit-Change-Id: I8cb2cb083e3cdadf187b7874979d79af3974e759 Gerrit-Change-Number: 368 Gerrit-PatchSet: 2 Gerrit-Owner: stipa Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-Attention: stipa Gerrit-MessageType: newpatchset --K7AUZ8yJrKM= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos, stipa. <= /p>

stipa uploaded patch set #2 to this change.

View Change

The following approvals got outdated and were removed: Code-Review+2 by flichtenheld, Code-Review+2 by plaisthos

The change = is no longer submittable: Code-Review and checks~ChecksSubmitRule are unsat= isfied now.

dco: warn if DATA_V1 packets are sent to userspace

Serve= rs 2.4.0 - 2.4.4 support peer-id and AEAD ciphers,
but only send DATA_V1= packets. With DCO enabled on the
client, connection is established but = not working.

This is because DCO driver(s) are unable to handle
D= ATA_V1 packets and forwards them to userspace, where
they silently disap= pear since crypto context is in
DCO and not in userspace.

Startin= g from 2.4.5 server sends DATA_V2 so problem
doesn't happen.

= We cannot switch to non-DCO on the fly, so we log this
and advice user t= o upgrade the server to 2.4.5 or newer.

This fixes https://github.co= m/OpenVPN/openvpn/issues/422

Change-Id: I8cb2cb083e3cdadf187b7874979= d79af3974e759
Signed-off-by: Lev Stipakov <lev@...515...>
---M src/openvpn/forward.c
1 file changed, 20 insertions(+), 3 deletions(= -)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/6=
8/368/2
diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c<=
/span>
index d8ad0d1..40f21bc 100644
--- a/src/ope= nvpn/forward.c
+++ b/src/openvpn/forward.c
= @@ -1047,6 +1047,24 @@

if (c->= ;c2.tls_multi)
{
+ uint8_t opcode =3D *BPTR(&c->c2.bu= f) >> P_OPCODE_SHIFT;
+
+ = /*
+ * I= f DCO is enabled, the kernel drivers require that the
+ * other end only sends P_DAT= A_V2 packets. V1 are unknown
+ * to kernel and passed to userland, but we cannot han= dle them
+ = * either because crypto context is missing - so drop the packet.+ *
+ * This can only happ= en with particular old (2.4.0-2.4.4) servers.

+ */
+ if ((opcode =3D=3D P_DATA_V1) && = dco_enabled(&c->options))
+ {
+ msg(D_LINK_ERRORS,
+ "Data Channel Offload doesn&= #39;t support DATA_V1 packets. "
+ "Upgrade your server to 2.4.5 or= newer.");
+ = c->c2.buf.len =3D 0;
+ }
+
/*
* = If tls_pre_decrypt returns true, it means the incoming
= * packet was a good TLS control channel packet. If so, TLS code<= /span>
@@ -1057,9 +1075,8 @@
* will = load crypto_options with the correct encryption key
= * and return false.
*/
- uint8_t opcode =3D *BPTR(= &c->c2.buf) >> P_OPCODE_SHIFT;

- if (tls_pre_decrypt(c->c2.tls_multi, &= amp;c->c2.from, &c->c2.buf, &co,
- floated, &ad_s= tart))
+ i= f (tls_pre_decrypt(c->c2.tls_multi, &c->c2.from, &c->c2.bu= f,
+ = &co, floated, &ad_start))
= {
/* Restore pre-NCP frame parameters *= /
if (is_hard_reset_method2(opcode))

To view, visit change 368. To unsubscribe, or for= help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: I8cb2cb083e3cdadf187b7874979= d79af3974e759
Gerrit-Change-Number: 368
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <lstipakov@...277...>= ;
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-Attention: stipa <lstipakov@...1663...= .>
Gerrit-MessageType: newpatchset
--K7AUZ8yJrKM=--