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 2FEDD91F82 for ; Thu, 5 Oct 2023 10:56:59 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 40F131565F for ; Thu, 5 Oct 2023 10:56:28 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 5 Oct 2023 10:56:26 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2455244853 for ; Thu, 5 Oct 2023 10:56:26 +0200 (CEST) Date: Thu, 05 Oct 2023 10:56:19 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20230809083739.100024-1-m.frank@proxmox.com> <20230809083739.100024-6-m.frank@proxmox.com> In-Reply-To: <20230809083739.100024-6-m.frank@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1696495486.8njpavz612.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.062 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 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. [qemu.pm, proxmox.com] Subject: Re: [pve-devel] [PATCH qemu-server v7 5/11] Permission check for virtiofs directory access 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: Thu, 05 Oct 2023 08:56:59 -0000 this should likely also be added to PVE::QemuServer::check_mappings so that cloning and restoring are covered (properly).. checking permission for deletion is also not handled AFAICT, or for reverting pending changes - basically, everywhere bridge or PCI/USB mapping access is checked, Dir mapping access should be as well ;) On August 9, 2023 10:37 am, Markus Frank wrote: > Signed-off-by: Markus Frank > --- > PVE/API2/Qemu.pm | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) >=20 > diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm > index 9606e72..65830f9 100644 > --- a/PVE/API2/Qemu.pm > +++ b/PVE/API2/Qemu.pm > @@ -586,6 +586,19 @@ my $check_vm_create_serial_perm =3D sub { > return 1; > }; > =20 > +my sub check_vm_dir_perm { > + my ($rpcenv, $authuser, $param) =3D @_; > + > + return 1 if $authuser eq 'root@pam'; > + > + foreach my $opt (keys %{$param}) { > + next if $opt !~ m/^virtiofs\d+$/; > + my $virtiofs =3D PVE::JSONSchema::parse_property_string('pve-qm-virtiof= s', $param->{$opt}); > + $rpcenv->check_full($authuser, "/mapping/dir/$virtiofs->{dirid}", ['Map= ping.Use']); > + } > + return 1; > +}; > + > my sub check_usb_perm { > my ($rpcenv, $authuser, $vmid, $pool, $opt, $value) =3D @_; > =20 > @@ -687,6 +700,8 @@ my $check_vm_modify_config_perm =3D sub { > # the user needs Disk and PowerMgmt privileges to change the vmstat= e > # also needs privileges on the storage, that will be checked later > $rpcenv->check_vm_perm($authuser, $vmid, $pool, ['VM.Config.Disk', = 'VM.PowerMgmt' ]); > + } elsif ($opt =3D~ m/^virtiofs\d$/) { > + $rpcenv->check_vm_perm($authuser, $vmid, $pool, ['VM.Config.Disk'])= ; > } else { > # catches args, lock, etc. > # new options will be checked here > @@ -925,6 +940,7 @@ __PACKAGE__->register_method({ > =20 > &$check_vm_modify_config_perm($rpcenv, $authuser, $vmid, $pool, [ k= eys %$param]); > =20 > + check_vm_dir_perm($rpcenv, $authuser, $param); > &$check_vm_create_serial_perm($rpcenv, $authuser, $vmid, $pool, $pa= ram); > check_vm_create_usb_perm($rpcenv, $authuser, $vmid, $pool, $param); > check_vm_create_hostpci_perm($rpcenv, $authuser, $vmid, $pool, $par= am); > @@ -1660,6 +1676,8 @@ my $update_vm_api =3D sub { > =20 > &$check_vm_modify_config_perm($rpcenv, $authuser, $vmid, undef, [key= s %$param]); > =20 > + check_vm_dir_perm($rpcenv, $authuser, $param); > + > &$check_storage_access($rpcenv, $authuser, $storecfg, $vmid, $param)= ; > =20 > PVE::QemuServer::check_bridge_access($rpcenv, $authuser, $param); > --=20 > 2.39.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20