From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id E76201FF173 for ; Mon, 25 Nov 2024 14:09:17 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F14E11325A; Mon, 25 Nov 2024 14:09:14 +0100 (CET) From: Filip Schauer To: pve-devel@lists.proxmox.com Date: Mon, 25 Nov 2024 14:09:08 +0100 Message-Id: <20241125130908.22076-1-f.schauer@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.028 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 Subject: [pve-devel] [PATCH container] fix #5907: ignore conflicting mount options for read-only mounts 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" When mounting volumes as read-only, certain mount options like "discard", "lazytime", and "noatime" are either ignored or can cause the mount to fail. For example, attempting to mount with "-t zfs" and "-o ro,discard" leads to an error: filesystem cannot be mounted due to invalid option 'discard'. This commit ensures that only valid mount options, such as "nodev", "noexec", and "nosuid", are applied to read-only mounts, avoiding potential mount failures. Signed-off-by: Filip Schauer --- src/PVE/LXC.pm | 8 ++++++-- src/PVE/LXC/Config.pm | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index e78e365..d01fafc 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -1865,11 +1865,16 @@ sub __mountpoint_mount { die "unknown snapshot path for '$volid'" if !$storage && defined($snapname); + my $readonly = $mountpoint->{ro}; my $optlist = []; if (my $mountopts = $mountpoint->{mountoptions}) { my @opts = split(/;/, $mountpoint->{mountoptions}); - push @$optlist, grep { PVE::LXC::Config::is_valid_mount_option($_) } @opts; + if ($readonly || defined($snapname)) { + push @$optlist, grep { PVE::LXC::Config::is_valid_ro_mount_option($_) } @opts; + } else { + push @$optlist, grep { PVE::LXC::Config::is_valid_mount_option($_) } @opts; + } } my $acl = $mountpoint->{acl}; @@ -1880,7 +1885,6 @@ sub __mountpoint_mount { } my $optstring = join(',', @$optlist); - my $readonly = $mountpoint->{ro}; my @extra_opts; @extra_opts = ('-o', $optstring) if $optstring; diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm index 5cc37f7..0740e8c 100644 --- a/src/PVE/LXC/Config.pm +++ b/src/PVE/LXC/Config.pm @@ -312,12 +312,18 @@ cfs_register_file('/lxc/', \&parse_pct_config, \&write_pct_config); my $valid_mount_option_re = qr/(discard|lazytime|noatime|nodev|noexec|nosuid)/; +my $valid_ro_mount_option_re = qr/(nodev|noexec|nosuid)/; sub is_valid_mount_option { my ($option) = @_; return $option =~ $valid_mount_option_re; } +sub is_valid_ro_mount_option { + my ($option) = @_; + return $option =~ $valid_ro_mount_option_re; +} + my $rootfs_desc = { volume => { type => 'string', -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel