all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH container/manager v3 0/2] add a deny-write option for device passthrough
@ 2024-09-09 12:50 Filip Schauer
  2024-09-09 12:50 ` [pve-devel] [PATCH container v3 1/2] add " Filip Schauer
  2024-09-09 12:50 ` [pve-devel] [PATCH manager v3 2/2] ui: lxc: add readonly " Filip Schauer
  0 siblings, 2 replies; 5+ messages in thread
From: Filip Schauer @ 2024-09-09 12:50 UTC (permalink / raw)
  To: pve-devel

Add the deny-write options for device passthrough, to restrict container
access to devices.

This allows for passing through a device in read-only mode without
giving the container full access to it.

Up until now a container with a device passed through to it was granted
full access to that device without an option to restrict that access as
pointed out by @Fiona.

Changes since v1:
* set default values for deny_read & deny_write
* remove the deny_read checkbox from the UI, since it is expected to
  only have a very niche use case.

Changes since v2:
* remove the deny_read option due to a lack of use-cases
* rename deny_write to deny-write

pve-container:

Filip Schauer (1):
  add deny-write option for device passthrough

 src/PVE/LXC.pm        | 7 ++++++-
 src/PVE/LXC/Config.pm | 6 ++++++
 2 files changed, 12 insertions(+), 1 deletion(-)


pve-manager:

Filip Schauer (1):
  ui: lxc: add readonly option for device passthrough

 www/manager6/lxc/DeviceEdit.js | 8 ++++++++
 1 file changed, 8 insertions(+)


Summary over all repositories:
  3 files changed, 20 insertions(+), 1 deletions(-)

-- 
Generated by git-murpp 0.6.0


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] [PATCH container v3 1/2] add deny-write option for device passthrough
  2024-09-09 12:50 [pve-devel] [PATCH container/manager v3 0/2] add a deny-write option for device passthrough Filip Schauer
@ 2024-09-09 12:50 ` Filip Schauer
  2024-09-10 14:36   ` [pve-devel] applied: " Thomas Lamprecht
  2024-09-09 12:50 ` [pve-devel] [PATCH manager v3 2/2] ui: lxc: add readonly " Filip Schauer
  1 sibling, 1 reply; 5+ messages in thread
From: Filip Schauer @ 2024-09-09 12:50 UTC (permalink / raw)
  To: pve-devel

Add the deny-write options for device passthrough, to restrict container
access to devices.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
---
 src/PVE/LXC.pm        | 7 ++++++-
 src/PVE/LXC/Config.pm | 6 ++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 65d0fa8..cb24f2d 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -651,7 +651,12 @@ sub update_lxc_config {
 	my $major = PVE::Tools::dev_t_major($rdev);
 	my $minor = PVE::Tools::dev_t_minor($rdev);
 	my $device_type_char = S_ISBLK($mode) ? 'b' : 'c';
-	$raw .= "lxc.cgroup2.devices.allow = $device_type_char $major:$minor rw\n";
+	my $allow_perms = "r" . $device->{'deny-write'} ? "" : "w";
+	$raw .= "lxc.cgroup2.devices.allow = $device_type_char $major:$minor $allow_perms\n";
+
+	if ($device->{'deny-write'}) {
+	    $raw .= "lxc.cgroup2.devices.deny = $device_type_char $major:$minor w\n";
+	}
     });
 
     # WARNING: DO NOT REMOVE this without making sure that loop device nodes
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index 1664a35..ce64c4c 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -962,6 +962,12 @@ my $dev_desc = {
 	minimum => 0,
 	description => 'Group ID to be assigned to the device node',
     },
+    'deny-write' => {
+	optional => 1,
+	type => 'boolean',
+	description => 'Deny the container to write to the device',
+	default => 0,
+    },
 };
 
 for (my $i = 0; $i < $MAX_DEVICES; $i++) {
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] [PATCH manager v3 2/2] ui: lxc: add readonly option for device passthrough
  2024-09-09 12:50 [pve-devel] [PATCH container/manager v3 0/2] add a deny-write option for device passthrough Filip Schauer
  2024-09-09 12:50 ` [pve-devel] [PATCH container v3 1/2] add " Filip Schauer
@ 2024-09-09 12:50 ` Filip Schauer
  2024-10-24 17:23   ` [pve-devel] applied: " Thomas Lamprecht
  1 sibling, 1 reply; 5+ messages in thread
From: Filip Schauer @ 2024-09-09 12:50 UTC (permalink / raw)
  To: pve-devel

Add a checkbox to the device passthrough dialogue for restricting
write access to a device passed through to a container.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
---
 www/manager6/lxc/DeviceEdit.js | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/www/manager6/lxc/DeviceEdit.js b/www/manager6/lxc/DeviceEdit.js
index cdbd9acc..9aadb2ff 100644
--- a/www/manager6/lxc/DeviceEdit.js
+++ b/www/manager6/lxc/DeviceEdit.js
@@ -95,6 +95,13 @@ Ext.define('PVE.lxc.DeviceInputPanel', {
 		return gettext("Access mode has to be an octal number");
 	    },
 	},
+	{
+	    xtype: 'checkbox',
+	    name: 'deny-write',
+	    fieldLabel: gettext('Read only'),
+	    labelWidth: 120,
+	    checked: false,
+	},
     ],
 });
 
@@ -145,6 +152,7 @@ Ext.define('PVE.lxc.DeviceEdit', {
 		    mode: data.mode,
 		    uid: data.uid,
 		    gid: data.gid,
+		    'deny-write': data['deny-write'],
 		};
 
 		ipanel.setValues(values);
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] applied: [PATCH container v3 1/2] add deny-write option for device passthrough
  2024-09-09 12:50 ` [pve-devel] [PATCH container v3 1/2] add " Filip Schauer
@ 2024-09-10 14:36   ` Thomas Lamprecht
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Lamprecht @ 2024-09-10 14:36 UTC (permalink / raw)
  To: Proxmox VE development discussion, Filip Schauer

Am 09/09/2024 um 14:50 schrieb Filip Schauer:
> Add the deny-write options for device passthrough, to restrict container
> access to devices.
> 
> Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
> ---
>  src/PVE/LXC.pm        | 7 ++++++-
>  src/PVE/LXC/Config.pm | 6 ++++++
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
>

applied, thanks!


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] applied: [PATCH manager v3 2/2] ui: lxc: add readonly option for device passthrough
  2024-09-09 12:50 ` [pve-devel] [PATCH manager v3 2/2] ui: lxc: add readonly " Filip Schauer
@ 2024-10-24 17:23   ` Thomas Lamprecht
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Lamprecht @ 2024-10-24 17:23 UTC (permalink / raw)
  To: Proxmox VE development discussion, Filip Schauer

Am 09/09/2024 um 14:50 schrieb Filip Schauer:
> Add a checkbox to the device passthrough dialogue for restricting
> write access to a device passed through to a container.
> 
> Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
> ---
>  www/manager6/lxc/DeviceEdit.js | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
>

applied this one now too, thanks!


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-10-24 17:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-09 12:50 [pve-devel] [PATCH container/manager v3 0/2] add a deny-write option for device passthrough Filip Schauer
2024-09-09 12:50 ` [pve-devel] [PATCH container v3 1/2] add " Filip Schauer
2024-09-10 14:36   ` [pve-devel] applied: " Thomas Lamprecht
2024-09-09 12:50 ` [pve-devel] [PATCH manager v3 2/2] ui: lxc: add readonly " Filip Schauer
2024-10-24 17:23   ` [pve-devel] applied: " Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal