5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-01-06 13:17:56 +03:00

anchor CPU flag regex to avoid arbitrary flag suffixes

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 <o.bektas@proxmox.com>
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
Stefan Reiter 2021-01-18 14:07:52 +01:00 committed by Thomas Lamprecht
parent b08c37c363
commit 4893f9b970

View File

@ -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 };
}
}