[Openvpn-devel,v1] socket_util: check the address family in addr_match() and addr_port_match()
| Message ID | 20261123140843.1436-1-gert@greenie.muc.de |
|---|---|
| State | New |
| Headers |
Return-Path: <openvpn-devel-bounces@lists.sourceforge.net>
Delivered-To: patchwork@openvpn.net
Received: by 2002:a05:6022:91c9:10b0:11b:d6c:f273 with SMTP id
tl9-n1csp2804290lad;
Mon, 23 Nov 2026 06:08:54 -0800 (PST)
X-Forwarded-Encrypted: i=2;
AL+hErGnL7i6VadHXaQO/FOlpk/qpihZCvKo4f6uoDFkxsEw+RkMzVo/0a/MbxgqfDzgx7hGffXxbkP6VQ0=@openvpn.net
X-Received: by 2002:a05:6830:4105:b0:861:580a:e3d1 with SMTP id
46e09a7af769-863152d08d6mr15260026a34.3.1795442934161;
Mon, 23 Nov 2026 06:08:54 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1795442934; cv=none;
d=google.com; s=arc-20260327;
b=onnqsFnkAT+qg3+igZfPqv7Zim5f2BA1mgF/3tPSwfU1drj2vqv8ohxMrdrrXKleFi
bhkQlsmJad9PAEcZloO75wtQfv2rkhpB06C6jJXtr3+txgGhU0h9LwChnbOJP0ADQacx
q84YT4RDwjtDpmAu/QRAfEbR0r1uP7KniqquQnmwjFmGp6EvXCVg4PqW/e1fDUOXhMi2
61qulltQHjZyVOrrYTaLgFqzVvVb9APRAJiva7s2JtkFzRu02dMW9JV+OCYSt6xGuduC
qtkXejiRVSWPO7x7MpgQ6SjqSegDA3kYNwOeSVuhM8onYzmUZZznPWH/WDyy7wuby2mG
bJYQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20260327;
h=errors-to:content-transfer-encoding:list-subscribe:list-help
:list-post:list-archive:list-unsubscribe:list-id:precedence:subject
:mime-version:references:in-reply-to:message-id:date:to:from
:dkim-signature:dkim-signature:dkim-signature;
bh=8Unlz8aGrVitsKKLFw5f/JqZ/+4OIfunRGjYMTjQNiQ=;
fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=;
b=lDEwY/fEbm2KznfnwzBbSFhK85htiUKnnwhqNKhuQuEfxyQnmIEwmMOcorBMJAFw4U
VVzk6Ha2bwtP6X+DJFPYJ4gj3upyLymD0VTo27S8TaerKXOTvDd03CgdRU3dRQdP/mQs
kAISWQlbT+d4PTvymOa8zewCZEMm3kospkzs55VpMqEMRrIwrgk+NwDkRRsbHRUv8aU7
/gE1VBDlgNaKX90XY/jMFoOARbqrNEtw+XTL51iXpbQ8q34zBT2886XEgAAW6JrJ1Ttu
skLYEPChu4vA4lcEs+O2b23HpiKWCSA0LLE/n5zwDJFP1lr5pFHRGPMYmmZc0KrlomkD
0MNA==;
dara=google.com
ARC-Authentication-Results: i=1; mx.google.com;
dkim=pass header.i=@lists.sourceforge.net header.s=beta
header.b=DJsFTLAa;
dkim=neutral (body hash did not verify) header.i=@sourceforge.net
header.s=x header.b="LgUcJI/8";
dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x
header.b=PKdpBqZW;
spf=pass (google.com: domain of
openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as
permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net;
dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de
Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7])
by mx.google.com with ESMTPS id
46e09a7af769-863168df159si17870607a34.62.2026.11.23.06.08.53
(version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
Mon, 23 Nov 2026 06:08:54 -0800 (PST)
Received-SPF: pass (google.com: domain of
openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as
permitted sender) client-ip=216.105.38.7;
Authentication-Results: mx.google.com;
dkim=pass header.i=@lists.sourceforge.net header.s=beta
header.b=DJsFTLAa;
dkim=neutral (body hash did not verify) header.i=@sourceforge.net
header.s=x header.b="LgUcJI/8";
dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x
header.b=PKdpBqZW;
spf=pass (google.com: domain of
openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as
permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net;
dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:
List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:
Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender:
Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From:
Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post:
List-Owner; bh=8Unlz8aGrVitsKKLFw5f/JqZ/+4OIfunRGjYMTjQNiQ=; b=DJsFTLAaS5Td3c
K65FCh42ocYVf/1DDNVZPfb5ouGL0Qo/2L9Rk6P9BPD/lzh3m10fNCsF991aWgbrVkoLa7XnxrQrU
/n5SGZu+fKZOvcyjk5g8ZOQakYFBCpDQRG40cPWHjgt/lRtJfYRu5LurMmx0J0syFyqDFRcAZiHIK
KMM=;
Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com)
by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.100.1)
(envelope-from <openvpn-devel-bounces@lists.sourceforge.net>)
id 1xVUiy-000000003ql-2ob4;
Mon, 23 Nov 2026 14:08:52 +0000
Received: from [172.30.29.66] (helo=mx.sourceforge.net)
by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1)
(envelope-from <gert@blue4.greenie.muc.de>)
id 1xVUix-000000003qf-0eyl for openvpn-devel@lists.sourceforge.net;
Mon, 23 Nov 2026 14:08:51 +0000
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References:
In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:
Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive;
bh=unHeXGX6NMkVq8jt8uM/UH3nQH1cwg4NqsQ+BeXCLmQ=; b=LgUcJI/8nMC1fKqwlMK38qofzW
hmm8oQAtKyfvNhOHK8jm1iqYvq5NAlGrUDlMoG2r0eNWF+N0EJ53VIrU15FI9ySzYgrTcRixmxA+6
LJ+0OQWTlFSZ2MXeJxUP1uy5T5z/HhSgvg9jxuTdPkDGqiuGT2OSWDcCmYBA+A9sH+gQ=;
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x
;
h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:
Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID:
Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post:
List-Subscribe:List-Post:List-Owner:List-Archive;
bh=unHeXGX6NMkVq8jt8uM/UH3nQH1cwg4NqsQ+BeXCLmQ=; b=PKdpBqZWq/NQxQ6qkl3GDr3V/J
zAdCjGTCiMnowTL+6i6pmUKsL70iO6sf29aJiVRLlnMxNlG4B+kgZZ6dQbMvtP5NbVeQVN/8LnY7c
27Q6G2/KnFsEV4NN/8SlCzgJqFGl/0lXOtKCy+ZVInrR9GXdRf5HszzZPHcO3m3cS6p0=;
Received: from [193.149.48.129] (helo=blue.greenie.muc.de)
by sfi-mx-2.v28.lw.sourceforge.com with esmtps
(TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1)
id 1xVUiw-000000003sM-0UqY for openvpn-devel@lists.sourceforge.net;
Mon, 23 Nov 2026 14:08:51 +0000
Received: from blue.greenie.muc.de (localhost [127.0.0.1])
by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 6ANE8hLR001452
for <openvpn-devel@lists.sourceforge.net>; Mon, 23 Nov 2026 15:08:43 +0100
Received: (from gert@localhost)
by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6ANE8hdW001451
for openvpn-devel@lists.sourceforge.net; Mon, 23 Nov 2026 15:08:43 +0100
From: Gert Doering <gert@greenie.muc.de>
To: openvpn-devel@lists.sourceforge.net
Date: Mon, 23 Nov 2026 15:08:37 +0100
Message-ID: <20261123140843.1436-1-gert@greenie.muc.de>
X-Mailer: git-send-email 2.55.0
In-Reply-To:
<gerrit.1795432288000.Idd4d71d02bafece74871a8b88b1c12d03d58540f@gerrit.openvpn.net>
References:
<gerrit.1795432288000.Idd4d71d02bafece74871a8b88b1c12d03d58540f@gerrit.openvpn.net>
MIME-Version: 1.0
X-Spam-Score: 1.3 (+)
X-Spam-Report: Spam detection software,
running on the system "sfi-spamd-2.hosts.colo.sdot.me",
has NOT identified this incoming email as spam. The original
message has been attached to this so you can view it or label
similar future email. If you have any questions, see
the administrator of that system for details.
Content preview: From: Razvan Cojocaru <razvanc@mailbox.org> Both read a2 as
if it had a1's address family. The arguments are openvpn_sockaddr unions,
so the reads stay in bounds,
but a mixed pair compared an IPv4 address against
sin6_flowinfo, or an IPv6 addre [...]
Content analysis details: (1.3 points, 5.0 required)
pts rule name description
---- ----------------------
--------------------------------------------------
1.3 RDNS_NONE Delivered to internal network by a host with no rDNS
X-Headers-End: 1xVUiw-000000003sM-0UqY
Subject: [Openvpn-devel] [PATCH v1] socket_util: check the address family in
addr_match() and addr_port_match()
X-BeenThere: openvpn-devel@lists.sourceforge.net
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <openvpn-devel.lists.sourceforge.net>
List-Unsubscribe: <https://lists.sourceforge.net/lists/options/openvpn-devel>,
<mailto:openvpn-devel-request@lists.sourceforge.net?subject=unsubscribe>
List-Archive:
<http://sourceforge.net/mailarchive/forum.php?forum_name=openvpn-devel>
List-Post: <mailto:openvpn-devel@lists.sourceforge.net>
List-Help: <mailto:openvpn-devel-request@lists.sourceforge.net?subject=help>
List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/openvpn-devel>,
<mailto:openvpn-devel-request@lists.sourceforge.net?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: openvpn-devel-bounces@lists.sourceforge.net
X-getmail-retrieved-from-mailbox: Inbox
X-GMAIL-THRID: 1882658369943147879
X-GMAIL-MSGID: 1882658369943147879
|
| Series |
[Openvpn-devel,v1] socket_util: check the address family in addr_match() and addr_port_match()
|
|
Commit Message
Gert Doering
Nov. 23, 2026, 2:08 p.m. UTC
From: Razvan Cojocaru <razvanc@mailbox.org> Both read a2 as if it had a1's address family. The arguments are openvpn_sockaddr unions, so the reads stay in bounds, but a mixed pair compared an IPv4 address against sin6_flowinfo, or an IPv6 address against sin_zero and the bytes after it. Mixed pairs reach link_socket_actual_match() when a client floats between an IPv4 and an IPv6 --local. Return no match for a different family, as addrlist_match() does. Change-Id: Idd4d71d02bafece74871a8b88b1c12d03d58540f Signed-off-by: Razvan Cojocaru <razvanc@mailbox.org> Acked-by: Frank Lichtenheld <frank@lichtenheld.com> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2327 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2327 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld <frank@lichtenheld.com>
diff --git a/src/openvpn/socket_util.h b/src/openvpn/socket_util.h index e85f6fe..a7821df 100644 --- a/src/openvpn/socket_util.h +++ b/src/openvpn/socket_util.h @@ -294,6 +294,10 @@ static inline bool addr_match(const struct openvpn_sockaddr *a1, const struct openvpn_sockaddr *a2) { + if (a1->addr.sa.sa_family != a2->addr.sa.sa_family) + { + return false; + } switch (a1->addr.sa.sa_family) { case AF_INET: @@ -381,6 +385,10 @@ static inline bool addr_port_match(const struct openvpn_sockaddr *a1, const struct openvpn_sockaddr *a2) { + if (a1->addr.sa.sa_family != a2->addr.sa.sa_family) + { + return false; + } switch (a1->addr.sa.sa_family) { case AF_INET: