From patchwork Tue Nov 10 11:20:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5644 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:20a6:b0:11a:a05e:cb97 with SMTP id 38csp888341lad; Tue, 10 Nov 2026 03:21:11 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErG1Oia6wZK17MpyLv5AcXJ4SFUpFxnLj3cZtnNhkRj5ey86QlTiCW7kqTRnVBw4AAb6mvvyqoKDLBk=@openvpn.net X-Received: by 2002:a05:693c:4092:b0:375:b766:9172 with SMTP id 5a478bee46e88-375b766965bmr1543449eec.16.1794309671309; Tue, 10 Nov 2026 03:21:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794309671; cv=none; d=google.com; s=arc-20260327; b=ScW8QIJdT7oYqPyxADsSvZYbOr9uQT9OuFTG5LV9WEKg8OhmDt8wNz6zdilkrr2Q00 uJ1zCn1LIHptajnHThGe6N6+hKcQjZptDVtzB5lfGAusqUDiJTRHyh6hGArNgwV2ZWoz K1qsAGyj2SblFPVMBQJvE3XvYzh28cIvswYVrz3+4jOOipEwuQmm3v8RdWcLA2MTFaXZ c5d6KD73+aini9T9AAb6W4tkbg8nhW/x3KI8adzz2ieVFUE11wgjlRI9Z+b/R9aX2tmv sY7ZnCik0wZXeAuQi8M+M0SS+Fzj4MDzvCjyUhDgGHJ3ZwAKTZ++BOHBFb4I1Ai2PjLh p2GA== 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=Qm8pWRJyNf2EYkj8t7SMVdiiKBVeSCv7EBy/ngRpXu8=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=UeAb7CsUOMp6LKsTIbCEsnYvbn3n/8kVqlFKNEG9N7KVXtQo85iz0HjUFAuWgzWkvw U+DdO8uk59KWoGLiKWBeMZy2qUPiKMaH3rBzc07AK/ZEcJL8tCzSCgdBsQkCtClpe0Rf 7k1g5kBLrHnE3Ely9RmL2P9YM6o7W5me2F2XMEHo9Q2ET595xoTzeTJ5mL3SneLINmCF B/EaZq8WeNBDaZn4nGPymk+5XMLZoGDbqLEaFJcaMrspW0KWyEk3pRWXrsmPQr8Ie96r XeuPLoPgYd58rUoC+kbws/24OjEU10qkjlAFTlNvCD7kaS5eNygzI0h+EhibkYJ/EQX/ FOPQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=VYf5cAhH; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=iJm3+JN1; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=ju6mFr1T; 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 5a478bee46e88-37520d04a0asi4829848eec.42.2026.11.10.03.21.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Nov 2026 03:21:11 -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=VYf5cAhH; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=iJm3+JN1; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=ju6mFr1T; 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=Qm8pWRJyNf2EYkj8t7SMVdiiKBVeSCv7EBy/ngRpXu8=; b=VYf5cAhHWRXowu aQUz4ufXnrcl4Wlx66ibREAe0hovJNJ7qXytEuxQ4ede/uKNaLcwFAhXSCGxPeOxMriYQRDF+IMGf 0HHnrKKjy5ZpZ+PESnS6LXdei5tuZTzB/Niphk/kgt1LD6xvD467tWEJF/9fbatIxTk9/DQm4dBnG 7GM=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xQjuY-0000000015h-0NVH; Tue, 10 Nov 2026 11:21:10 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xQjuW-0000000015a-1wVB for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 11:21:08 +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=MvtcopMaG5xmpSG7hBYzgJyZTSiczLgmJ6kUiYbqXgo=; b=iJm3+JN1Fvm8fLZ9Uynjn8GeNZ Gw6RUWQoFwKGb/JOaQ+67tn/DnFdeec0OM/zb9sjlWJ4I8XKvIZTDsfETBCIk1tJBis6I9pcaza1i +6WogrLigaXD85OzI25B2QuQS2qIvURfp788vX0hKj5jnDK01Iefu6r/9DFZuLDhQImw=; 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=MvtcopMaG5xmpSG7hBYzgJyZTSiczLgmJ6kUiYbqXgo=; b=ju6mFr1TgKlOsX9znIzec/LUfR muxzr7dU1Ydh+equEkadJQeAlqw6B/4trbEW5rS3VRsYEMYxGJhF4lAO7fw6CBRb/HloPtgp5Llrr wtz8LgsCzalmjtSS5f+iOLiOHF+5EjFjFwCesDN/AqdbAK7XO5tB5ECYCSq1bXQUBnzs=; 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 1xQjuU-0000000047T-2YET for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 11:21:08 +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 6AABKxQx030845 for ; Tue, 10 Nov 2026 12:20:59 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6AABKx6G030844 for openvpn-devel@lists.sourceforge.net; Tue, 10 Nov 2026 12:20:59 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 10 Nov 2026 12:20:53 +0100 Message-ID: <20261110112059.30832-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: 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 The inet_address_t locals were initialized with "= { 0 }", which only initializes the first union member, the 4 byte ipv4. GCC 15 and later no longer clear the rest of the union for this, so the IPv6 [...] 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: 1xQjuU-0000000047T-2YET Subject: [Openvpn-devel] [PATCH v2] sitnl: clear inet_address_t locals with CLEAR() X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1881470057748210456 X-GMAIL-MSGID: 1881470057748210456 From: Razvan Cojocaru The inet_address_t locals were initialized with "= { 0 }", which only initializes the first union member, the 4 byte ipv4. GCC 15 and later no longer clear the rest of the union for this, so the IPv6 addresses of these locals keep up to 12 bytes of stack garbage when the caller passes no address. net_route_v6_del() then sends a garbage RTA_GATEWAY for routes without a gateway, and the kernel refuses to delete them. net_route_v6_best_gw() looks up a garbage destination when asked for the default route. Clear the whole union with CLEAR() instead. The other inet_address_t locals are cleared the same way, so none relies on the partial initialization. Latent since c6542257 ("introduce sitnl: Simplified Interface To NetLink"). Change-Id: I5c52cc5c3aaad21d1c22f36f6451235302ea6c4f Signed-off-by: Razvan Cojocaru Acked-by: Antonio Quartulli Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2163 --- 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/+/2163 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Antonio Quartulli diff --git a/src/openvpn/networking_sitnl.c b/src/openvpn/networking_sitnl.c index 97ff7bd..eafb9f7 100644 --- a/src/openvpn/networking_sitnl.c +++ b/src/openvpn/networking_sitnl.c @@ -612,10 +612,12 @@ net_route_v6_best_gw(openvpn_net_ctx_t *ctx, const struct in6_addr *dst, struct in6_addr *best_gw, char *best_iface) { - inet_address_t dst_v6 = { 0 }; + inet_address_t dst_v6; char buf[INET6_ADDRSTRLEN]; int ret; + CLEAR(dst_v6); + if (dst) { dst_v6.ipv6 = *dst; @@ -640,10 +642,12 @@ net_route_v4_best_gw(openvpn_net_ctx_t *ctx, const in_addr_t *dst, in_addr_t *best_gw, char *best_iface) { - inet_address_t dst_v4 = { 0 }; + inet_address_t dst_v4; char buf[INET_ADDRSTRLEN]; int ret; + CLEAR(dst_v4); + if (dst) { dst_v4.ipv4 = htonl(*dst); @@ -1040,9 +1044,11 @@ int net_addr_v4_add(const openvpn_net_ctx_t *ctx, const char *iface, const in_addr_t *addr, int prefixlen) { - inet_address_t addr_v4 = { 0 }; + inet_address_t addr_v4; char buf[INET_ADDRSTRLEN]; + CLEAR(addr_v4); + if (!addr) { return -EINVAL; @@ -1060,9 +1066,11 @@ net_addr_v6_add(const openvpn_net_ctx_t *ctx, const char *iface, const struct in6_addr *addr, int prefixlen) { - inet_address_t addr_v6 = { 0 }; + inet_address_t addr_v6; char buf[INET6_ADDRSTRLEN]; + CLEAR(addr_v6); + if (!addr) { return -EINVAL; @@ -1079,9 +1087,11 @@ int net_addr_v4_del(const openvpn_net_ctx_t *ctx, const char *iface, const in_addr_t *addr, int prefixlen) { - inet_address_t addr_v4 = { 0 }; + inet_address_t addr_v4; char buf[INET_ADDRSTRLEN]; + CLEAR(addr_v4); + if (!addr) { return -EINVAL; @@ -1099,9 +1109,11 @@ net_addr_v6_del(const openvpn_net_ctx_t *ctx, const char *iface, const struct in6_addr *addr, int prefixlen) { - inet_address_t addr_v6 = { 0 }; + inet_address_t addr_v6; char buf[INET6_ADDRSTRLEN]; + CLEAR(addr_v6); + if (!addr) { return -EINVAL; @@ -1119,11 +1131,14 @@ net_addr_ptp_v4_add(const openvpn_net_ctx_t *ctx, const char *iface, const in_addr_t *local, const in_addr_t *remote) { - inet_address_t local_v4 = { 0 }; - inet_address_t remote_v4 = { 0 }; + inet_address_t local_v4; + inet_address_t remote_v4; char buf1[INET_ADDRSTRLEN]; char buf2[INET_ADDRSTRLEN]; + CLEAR(local_v4); + CLEAR(remote_v4); + if (!local) { return -EINVAL; @@ -1147,9 +1162,10 @@ net_addr_ptp_v4_del(const openvpn_net_ctx_t *ctx, const char *iface, const in_addr_t *local, const in_addr_t *remote) { - inet_address_t local_v4 = { 0 }; + inet_address_t local_v4; char buf[INET6_ADDRSTRLEN]; + CLEAR(local_v4); if (!local) { @@ -1227,11 +1243,14 @@ net_route_v6_add(const openvpn_net_ctx_t *ctx, const struct in6_addr *dst, int prefixlen, const struct in6_addr *gw, const char *iface, uint32_t table, int metric) { - inet_address_t dst_v6 = { 0 }; - inet_address_t gw_v6 = { 0 }; + inet_address_t dst_v6; + inet_address_t gw_v6; char dst_str[INET6_ADDRSTRLEN]; char gw_str[INET6_ADDRSTRLEN]; + CLEAR(dst_v6); + CLEAR(gw_v6); + if (dst) { dst_v6.ipv6 = *dst; @@ -1278,11 +1297,14 @@ net_route_v4_del(const openvpn_net_ctx_t *ctx, const in_addr_t *dst, int prefixlen, const in_addr_t *gw, const char *iface, uint32_t table, int metric) { - inet_address_t dst_v4 = { 0 }; - inet_address_t gw_v4 = { 0 }; + inet_address_t dst_v4; + inet_address_t gw_v4; char dst_str[INET_ADDRSTRLEN]; char gw_str[INET_ADDRSTRLEN]; + CLEAR(dst_v4); + CLEAR(gw_v4); + if (dst) { dst_v4.ipv4 = htonl(*dst); @@ -1304,11 +1326,14 @@ net_route_v6_del(const openvpn_net_ctx_t *ctx, const struct in6_addr *dst, int prefixlen, const struct in6_addr *gw, const char *iface, uint32_t table, int metric) { - inet_address_t dst_v6 = { 0 }; - inet_address_t gw_v6 = { 0 }; + inet_address_t dst_v6; + inet_address_t gw_v6; char dst_str[INET6_ADDRSTRLEN]; char gw_str[INET6_ADDRSTRLEN]; + CLEAR(dst_v6); + CLEAR(gw_v6); + if (dst) { dst_v6.ipv6 = *dst;