From: "cron2 (Code Review)" Date: Tue, 2 Sep 2025 17:00:59 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, ralf@...2726..., frank@...2641... Message-ID: <811d53bd731b9be46fa6af7f38e6959a63c05de6-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="pRhsZu4Sn5s="; 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: ralf_lici , plaisthos , flichtenheld Cc: openvpn-devel --pRhsZu4Sn5s= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#3) to the change originally created by= ralf_lici. ( http://gerrit.openvpn.net/c/openvpn/+/1166?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 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 Acked-by: Gert Doering Message-Id: <20250902164521.23145-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32= 768.html Signed-off-by: Gert Doering --- 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/3 diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index 6115d51..40674e7 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 (!c->c1.tuntap || c->c1.tuntap->dco.ifindex =3D=3D 0) + { + 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: 3 Gerrit-Owner: ralf_lici Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --pRhsZu4Sn5s= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #3 to the change originally cr= eated by ralf_lici.

View Change

The following approvals got outdate= d and were removed: Code-Review+2 by cron2

dco_linux: validate tun interface before fetching st=
ats

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 h= as 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 che= ck to ensure the tun interface was set up before attempting to
retrieve = peer statistics.

Change-Id: I40c11864745cc1619cb9cbf490b168f90feb5ea= c
Signed-off-by: Ralf Lici <ralf@...2726...>
Acked-by: Gert Doe= ring <gert@...1296...>
Message-Id: <20250902164521.23145-1-gert= @...1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1466...= urceforge.net/msg32768.html
Signed-off-by: Gert Doering <gert@...1726...= ...>
---
M src/openvpn/dco_linux.c
1 file changed, 7 insertions= (+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openv=
pn refs/changes/66/1166/3
diff --git a/src/openvpn/dco_linux.c b/sr=
c/openvpn/dco_linux.c
index 6115d51..40674e7 100644<= br>--- a/src/openvpn/dco_linux.c
+++ b/src/openvpn/dc= o_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 "du= mp all peers", but this is allowed in MP mode only.
= * If it happens in P2P mode it means 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)
{
<= span style=3D"color: hsl(120, 100%, 40%);">+ if (!c->c1.tuntap || c-&= gt;c1.tuntap->dco.ifindex =3D=3D 0)
+ {
+ return -1;
+ }
+ return dco_get_peer(&c->c1.tuntap->dco, c->c2.tls_= multi->dco_peer_id, raise_sigusr1_on_err);
}
=

To view, visit change 1166. To unsu= bscribe, 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: 3
Gerrit-Owner: ralf_lici <ralf@...2726...>= ;
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: newpatchset
--pRhsZu4Sn5s=--