From: "cron2 (Code Review)" Date: Sun, 22 Oct 2023 10:49:06 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., lstipakov@...277... Message-ID: <443b081af9d3342fc0c5bbd059f473635ace46bd-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="rbjT9k3x2z0="; 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: stipa Cc: plaisthos , flichtenheld , openvpn-devel --rbjT9k3x2z0= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/36= 8?usp=3Demail ) 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. Github: fixes OpenVPN/openvpn#422 Change-Id: I8cb2cb083e3cdadf187b7874979d79af3974e759 Signed-off-by: Lev Stipakov Acked-by: Gert Doering Message-Id: <20231022082751.8868-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27= 272.html Signed-off-by: Gert Doering (cherry picked from commit df7beea404df48745a608c584d863c5a377b7a1e) --- M src/openvpn/forward.c 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index d8ad0d1..2510410 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,7 +1075,6 @@ * 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)) { -- 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: 4 Gerrit-Owner: stipa Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --rbjT9k3x2z0= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

dco: warn if DATA_V1 packets are sent to users=
pace

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 unab= le to handle
DATA_V1 packets and forwards them to userspace, where
th= ey silently disappear since crypto context is in
DCO and not in userspac= e.

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.

Github: fix= es OpenVPN/openvpn#422

Change-Id: I8cb2cb083e3cdadf187b7874979d79af3= 974e759
Signed-off-by: Lev Stipakov <lev@...515...>
Acked-by: G= ert Doering <gert@...1296...>
Message-Id: <20231022082751.8868-= 1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1224...= sts.sourceforge.net/msg27272.html
Signed-off-by: Gert Doering <gert@...220...= ..1296...>
(cherry picked from commit df7beea404df48745a608c584d863c5= a377b7a1e)
---
M src/openvpn/forward.c
1 file changed, 18 insertio= ns(+), 1 deletion(-)

diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c
index d8ad0d1..2510410 100644
--- a/src/openvpn/forward.= c
+++ b/src/openvpn/forward.c
@@ -1047,6 +1= 047,24 @@

if (c->c2.tls_multi= )
{
+ uint8_t opcode =3D *BPTR(&c->c2.buf) >> P= _OPCODE_SHIFT;
+
+ /*+ * If DCO is enab= led, 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 be= cause crypto context is missing - so drop the packet.
+ *
+ * This can only happen with parti= cular old (2.4.0-2.4.4) servers.
+ */
+ if ((opcode =3D=3D P_DATA_V1) && dco_enabled(&= amp;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_de= crypt returns true, it means the incoming
* p= acket was a good TLS control channel packet. If so, TLS code
@@ -1057,7 +1075,6 @@

* will load crypto_o= ptions with the correct encryption key
* and = return false.
*/
- uint8_t opcode =3D *BPTR(&c->c2= .buf) >> P_OPCODE_SHIFT;
if (tls_pre_dec= rypt(c->c2.tls_multi, &c->c2.from, &c->c2.buf, &co,
floated, &ad_start))

{

To view, vi= sit chang= e 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: 4
Gerrit-Owner: stipa <lstipakov@...277...>= ;
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--rbjT9k3x2z0=--