From: "its_Giaan (Code Review)" Date: Mon, 1 Dec 2025 21:16:25 +0000 In-Reply-To: References: Reply-To: gianmarco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., gert@...1296... Message-ID: <8569ebe67ba12df5cc37738748dcea9372ed5ab5-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="RAqkrufMPVs="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: mudp: fix unaligned 32-bit read when parsing peer ID List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --RAqkrufMPVs= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: cron2, its_Giaan, plaisthos. Hello flichtenheld, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1348?usp=3Demail to look at the new patch set (#3). Change subject: mudp: fix unaligned 32-bit read when parsing peer ID ...................................................................... mudp: fix unaligned 32-bit read when parsing peer ID The code previously read a 32-bit value from a uint8_t buffer using a direct cast and dereference. This can cause unaligned memory access and undefined behavior on architectures that do not support unaligned reads, potentially leading to a one-packet crash. Fix this by reading the bytes individually and combining them manually. Reported-By: Joshua Rogers Found-By: ZeroPath (https://zeropath.com) Change-Id: Id0bb4c45d373437ab8dbaff7a311745f9b538cbf Signed-off-by: Gianmarco De Gregori --- M src/openvpn/mudp.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/48/1348/3 diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index b03e165..5de3af6 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -209,7 +209,7 @@ /* make sure buffer has enough length to read opcode (1 byte) and = peer-id (3 bytes) */ if (v2) { - uint32_t peer_id =3D ntohl(*(uint32_t *)ptr) & 0xFFFFFF; + uint32_t peer_id =3D ((uint32_t)ptr[1] << 16) | ((uint32_t)ptr= [2] << 8) | ((uint32_t)ptr[3]); peer_id_disabled =3D (peer_id =3D=3D MAX_PEER_ID); if (!peer_id_disabled && (peer_id < m->max_clients) && (m->ins= tances[peer_id])) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1348?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Id0bb4c45d373437ab8dbaff7a311745f9b538cbf Gerrit-Change-Number: 1348 Gerrit-PatchSet: 3 Gerrit-Owner: its_Giaan Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: cron2 Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: its_Giaan Gerrit-Attention: cron2 --RAqkrufMPVs= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: cron2, its_Giaan, plaisthos.

its_Giaan uploaded patch set #3 to this change.

<= a href=3D"http://gerrit.openvpn.net/c/openvpn/+/1348?usp=3Demail">View Chan= ge

mudp: fix unaligned 32-bit read when parsing peer I=
D

The code previously read a 32-bit value from a uint8_t
buffer u= sing a direct cast and dereference.
This can cause unaligned memory acce= ss and undefined
behavior on architectures that do not support unaligned=
reads, potentially leading to a one-packet crash.

Fix this by re= ading the bytes individually and
combining them manually.

Reporte= d-By: Joshua Rogers <contact@...2949...>
Found-By: ZeroPath (https= ://zeropath.com)

Change-Id: Id0bb4c45d373437ab8dbaff7a311745f9b538cb= f
Signed-off-by: Gianmarco De Gregori <gianmarco@...2726...>
--= -
M src/openvpn/mudp.c
1 file changed, 1 insertion(+), 1 deletion(-)<= br>
git pull ssh://gerrit.openvpn.net:29418/openvpn =
refs/changes/48/1348/3
diff --git a/src/openvpn/mudp.c b/src/openvp=
n/mudp.c
index b03e165..5de3af6 100644
--- = a/src/openvpn/mudp.c
+++ b/src/openvpn/mudp.c
@@ -209,7 +209,7 @@
/* make sure buffer has eno= ugh length to read opcode (1 byte) and peer-id (3 bytes) */
if (v2)
{
- uint32_t peer_id =3D ntohl(*(uint32_t *)= ptr) & 0xFFFFFF;
= + uint32_t peer_id =3D ((uint32_t)ptr[1] << 16) | ((uint32= _t)ptr[2] << 8) | ((uint32_t)ptr[3]);
pe= er_id_disabled =3D (peer_id =3D=3D MAX_PEER_ID);
if (!peer_id_disabled && (peer_id < m->m= ax_clients) && (m->instances[peer_id]))
<= br>

To view, visit change 1348. To unsubscribe, or for help writing mai= l filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0bb4c45d373437ab8dbaff7a31= 1745f9b538cbf
Gerrit-Change-Number: 1348
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <gianmarco@...2786...= ..>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: cron2 <gert@...1296...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: its_Giaan <gianmarco@...1665...= 726...>
Gerrit-Attention: cron2 <gert@...1296...>= ;
= --RAqkrufMPVs=--