From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id CD9AB1FF164 for ; Wed, 25 Sep 2024 13:39:34 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 692E11F11A; Wed, 25 Sep 2024 13:39:46 +0200 (CEST) From: Daniel Kral To: pve-devel@lists.proxmox.com Date: Wed, 25 Sep 2024 13:39:29 +0200 Message-Id: <20240925113930.92754-1-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.002 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [network.pm] Subject: [pve-devel] [PATCH common 1/2] fix #5454: net: check names for vlan bridge slave interfaces X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Adds a check for the name of VLAN bridge slave interfaces, which are created on non VLAN-aware bridges. These checks mimics what is done when parsing an interface name in iproute2 [0], which includes a name size check, an empty string check and checking for invalid characters. Without this check, creating a VLAN bridge slave interface, where the length of the string "." will be greater than or equal to 16 characters, resulted in the following error message from `ip` itself: > Error: argument "." is wrong: "name" not a valid ifname [0] https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/lib/utils.c?h=v6.1.0#n825 Signed-off-by: Daniel Kral --- src/PVE/Network.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm index a4f5ba9..dd627f2 100644 --- a/src/PVE/Network.pm +++ b/src/PVE/Network.pm @@ -165,6 +165,22 @@ my $compute_fwbr_names = sub { return ($fwbr, $vethfw, $vethfwpeer, $ovsintport); }; +sub check_iface_name : prototype($) { + my ($name) = @_; + + my $name_len = length($name); + + # iproute2 / kernel have a strict interface name size limit + die "the interface name $name is too long" + if $name_len >= PVE::ProcFSTools::IFNAMSIZ; + + # iproute2 checks with isspace(3), which includes vertical tabs (not catched with perl's '\s') + die "the interface name $name is empty or contains invalid characters" + if $name_len == 0 || $name =~ /\s|\v|\//; + + return 1; +} + sub iface_delete :prototype($) { my ($iface) = @_; run_command(['/sbin/ip', 'link', 'delete', 'dev', $iface], noerr => 1) @@ -561,6 +577,8 @@ sub activate_bridge_vlan_slave { # create vlan on $iface is not already exist if (! -d "/sys/class/net/$ifacevlan") { eval { + check_iface_name($ifacevlan); + my $cmd = ['/sbin/ip', 'link', 'add']; push @$cmd, 'link', $iface; push @$cmd, 'name', $ifacevlan; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel