From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 9132A6951F for ; Mon, 18 Jan 2021 14:08:08 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8281613437 for ; Mon, 18 Jan 2021 14:08:08 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 619FE1342E for ; Mon, 18 Jan 2021 14:08:04 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1EBF54604B for ; Mon, 18 Jan 2021 14:08:04 +0100 (CET) From: Stefan Reiter To: pve-devel@lists.proxmox.com Date: Mon, 18 Jan 2021 14:07:52 +0100 Message-Id: <20210118130752.19441-1-s.reiter@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.039 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH qemu-server] anchor CPU flag regex to avoid arbitrary flag suffixes 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: , X-List-Received-Date: Mon, 18 Jan 2021 13:08:08 -0000 Previously one could specify a CPU flag like 'pcidfoobar' and it would be accepted, even though we attempt to filter VM-only flags for security. AFAICT none of the flags we allow can be turned into any others just by appending text, but better safe than sorry. Reported-by: Oguz Bektas Signed-off-by: Stefan Reiter --- PVE/QemuServer/CPUConfig.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PVE/QemuServer/CPUConfig.pm b/PVE/QemuServer/CPUConfig.pm index 32192f2..b9981c8 100644 --- a/PVE/QemuServer/CPUConfig.pm +++ b/PVE/QemuServer/CPUConfig.pm @@ -214,7 +214,7 @@ sub validate_vm_cpu_conf { # in a VM-specific config, certain properties are limited/forbidden die "VM-specific CPU flags must be a subset of: @{[join(', ', @supported_cpu_flags)]}\n" - if ($cpu->{flags} && $cpu->{flags} !~ m/$cpu_flag_supported_re(;$cpu_flag_supported_re)*/); + if ($cpu->{flags} && $cpu->{flags} !~ m/^$cpu_flag_supported_re(;$cpu_flag_supported_re)*$/); die "Property 'reported-model' not allowed in VM-specific CPU config.\n" if defined($cpu->{'reported-model'}); @@ -442,7 +442,7 @@ sub parse_cpuflag_list { return $res if !$flaglist; foreach my $flag (split(";", $flaglist)) { - if ($flag =~ $re) { + if ($flag =~ m/^$re$/) { $res->{$2} = { op => $1, reason => $reason }; } } -- 2.20.1