From: "ralf_lici (Code Review)" Date: Tue, 2 Sep 2025 14:55:10 +0000 References: Reply-To: ralf@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <7531966e7a66daf7a04f83659936bc243d39f7dc-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="XMapXAdYExY="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: dco_linux: validate tun interface before fetching stats List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --XMapXAdYExY= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1166?usp=3Demail to review the following change. Change subject: dco_linux: validate tun interface before fetching stats ...................................................................... dco_linux: validate tun interface before fetching stats If dco_get_peer_stats() is called with an uninitialized c->c1.tuntap it results in a segfault. This issue happens when a client who has not connected to any server: - has --management and exits, - has --management and a management interface client issues either `bytecount` or `status` or - if SIGUSR2 is sent to it. Add a check to ensure the tun interface was set up before attempting to retrieve peer statistics. Change-Id: I40c11864745cc1619cb9cbf490b168f90feb5eac Signed-off-by: Ralf Lici --- M src/openvpn/dco_linux.c 1 file changed, 7 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/66/1166/1 diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index a3907fe..6e629c1 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -1139,6 +1139,8 @@ static int dco_get_peer(dco_context_t *dco, int peer_id, const bool raise_sigusr1_on_= err) { + ASSERT(dco); + /* peer_id =3D=3D -1 means "dump all peers", but this is allowed in MP= mode only. * If it happens in P2P mode it means that the DCO peer was deleted an= d we * can simply bail out @@ -1182,6 +1184,11 @@ int dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err) { + if (!tuntap_defined(c->c1.tuntap)) + { + return -1; + } + return dco_get_peer(&c->c1.tuntap->dco, c->c2.tls_multi->dco_peer_id, = raise_sigusr1_on_err); } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1166?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I40c11864745cc1619cb9cbf490b168f90feb5eac Gerrit-Change-Number: 1166 Gerrit-PatchSet: 1 Gerrit-Owner: ralf_lici Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --XMapXAdYExY= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

ralf_lici would like plaisthos and flichtenheld to review this change.

V= iew Change

dco_linux: validate tun interface before fetching stats
<= br>If dco_get_peer_stats() is called with an uninitialized c->c1.tuntap = it
results in a segfault. This issue happens when a client who has notconnected to any server:
- has --management and exits,
- has --= management and a management interface client issues either
`bytecoun= t` or `status` or
- if SIGUSR2 is sent to it.

Add a check to en= sure the tun interface was set up before attempting to
retrieve peer sta= tistics.

Change-Id: I40c11864745cc1619cb9cbf490b168f90feb5eac
Sig= ned-off-by: Ralf Lici <ralf@...2726...>
---
M src/openvpn/dco_l= inux.c
1 file changed, 7 insertions(+), 0 deletions(-)

git pul= l ssh://gerrit.openvpn.net:29418/openvpn refs/changes/66/1166/1
dif=
f --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c
index a3907fe..6e629c1 100644
--- a/src/openvpn/dco_linux.= c
+++ b/src/openvpn/dco_linux.c
@@ -1139,6 = +1139,8 @@
static int
dco_get_peer(dco_co= ntext_t *dco, int peer_id, const bool raise_sigusr1_on_err)
{
+ ASSERT(dco);=
+
= /* peer_id =3D=3D -1 means "dump all peers", but this is allow= ed in MP mode only.
* If it happens in P2P mode it me= ans that the DCO peer was deleted and we
* can simply= bail out
@@ -1182,6 +1184,11 @@
int

dco_get_peer_stats(struct context *c, const bool raise_sigusr1_= on_err)
{
+ if (!tuntap_defined(c->c1.tuntap))
+ {
+ return -1;
+ }
+=
return dco_get_peer(&c->c1.tuntap->dco, c-&= gt;c2.tls_multi->dco_peer_id, raise_sigusr1_on_err);
}<= /span>


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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I40c11864745cc1619cb9cbf490b= 168f90feb5eac
Gerrit-Change-Number: 1166
Gerrit-PatchSet: 1
Gerrit-Owner: ralf_lici <ralf@...2726...>= ;
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-MessageType: newchange
--XMapXAdYExY=--