all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH container] fix #5907: ignore conflicting mount options for read-only mounts
@ 2024-11-25 13:09 Filip Schauer
  2024-11-28 13:42 ` Fiona Ebner
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Filip Schauer @ 2024-11-25 13:09 UTC (permalink / raw)
  To: 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 <f.schauer@proxmox.com>
---
 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


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

* Re: [pve-devel] [PATCH container] fix #5907: ignore conflicting mount options for read-only mounts
  2024-11-25 13:09 [pve-devel] [PATCH container] fix #5907: ignore conflicting mount options for read-only mounts Filip Schauer
@ 2024-11-28 13:42 ` Fiona Ebner
  2024-11-28 14:56 ` Daniel Kral
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Fiona Ebner @ 2024-11-28 13:42 UTC (permalink / raw)
  To: Proxmox VE development discussion, Filip Schauer

Am 25.11.24 um 14:09 schrieb Filip Schauer:
> 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'.
> 

Things I didn't want to know (but luckily doesn't apply for mountpoints
here ;)):
https://utcc.utoronto.ca/~cks/space/blog/linux/NFSReadonlyAtime

> 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 <f.schauer@proxmox.com>
> ---

Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>


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


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

* Re: [pve-devel] [PATCH container] fix #5907: ignore conflicting mount options for read-only mounts
  2024-11-25 13:09 [pve-devel] [PATCH container] fix #5907: ignore conflicting mount options for read-only mounts Filip Schauer
  2024-11-28 13:42 ` Fiona Ebner
@ 2024-11-28 14:56 ` Daniel Kral
  2025-02-11 10:17 ` Fiona Ebner
  2025-02-11 12:15 ` [pve-devel] applied: " Thomas Lamprecht
  3 siblings, 0 replies; 6+ messages in thread
From: Daniel Kral @ 2024-11-28 14:56 UTC (permalink / raw)
  To: Proxmox VE development discussion, Filip Schauer

On 11/25/24 14:09, Filip Schauer wrote:
> 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 <f.schauer@proxmox.com>

I could reproduce the issue when backing up a container with at least 
one root disk or mountpoint, which has at least the mount option 
"discard" applied, and backing it up to a PBS instance (to stay close to 
the bug report I used v3.2.10-1 for this), while all images were stored 
on a ZFS pool.

After applying the patch, the container could be backed up to the same 
PBS instance without any trouble.

Reviewed-by: Daniel Kral <d.kral@proxmox.com>
Tested-by: Daniel Kral <d.kral@proxmox.com>


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


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

* Re: [pve-devel] [PATCH container] fix #5907: ignore conflicting mount options for read-only mounts
  2024-11-25 13:09 [pve-devel] [PATCH container] fix #5907: ignore conflicting mount options for read-only mounts Filip Schauer
  2024-11-28 13:42 ` Fiona Ebner
  2024-11-28 14:56 ` Daniel Kral
@ 2025-02-11 10:17 ` Fiona Ebner
  2025-02-11 12:17   ` Thomas Lamprecht
  2025-02-11 12:15 ` [pve-devel] applied: " Thomas Lamprecht
  3 siblings, 1 reply; 6+ messages in thread
From: Fiona Ebner @ 2025-02-11 10:17 UTC (permalink / raw)
  To: Proxmox VE development discussion, Filip Schauer

Ping

@Filip, you are more than welcome to ping your fixes after a while,
especially if they already have T-B and R-B :)

Am 25.11.24 um 14:09 schrieb Filip Schauer:
> 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 <f.schauer@proxmox.com>


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


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

* [pve-devel] applied: [PATCH container] fix #5907: ignore conflicting mount options for read-only mounts
  2024-11-25 13:09 [pve-devel] [PATCH container] fix #5907: ignore conflicting mount options for read-only mounts Filip Schauer
                   ` (2 preceding siblings ...)
  2025-02-11 10:17 ` Fiona Ebner
@ 2025-02-11 12:15 ` Thomas Lamprecht
  3 siblings, 0 replies; 6+ messages in thread
From: Thomas Lamprecht @ 2025-02-11 12:15 UTC (permalink / raw)
  To: Proxmox VE development discussion, Filip Schauer

Am 25.11.24 um 14:09 schrieb Filip Schauer:
> 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 <f.schauer@proxmox.com>
> ---
>  src/PVE/LXC.pm        | 8 ++++++--
>  src/PVE/LXC/Config.pm | 6 ++++++
>  2 files changed, 12 insertions(+), 2 deletions(-)
> 
>

applied, with Fiona's and Daniels R-b and T-b trailers, 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] 6+ messages in thread

* Re: [pve-devel] [PATCH container] fix #5907: ignore conflicting mount options for read-only mounts
  2025-02-11 10:17 ` Fiona Ebner
@ 2025-02-11 12:17   ` Thomas Lamprecht
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Lamprecht @ 2025-02-11 12:17 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fiona Ebner, Filip Schauer

Am 11.02.25 um 11:17 schrieb Fiona Ebner:
> @Filip, you are more than welcome to ping your fixes after a while,
> especially if they already have T-B and R-B 🙂

Thanks for your reminder on this series. FWIW, in such a case I think
one can also "ping" in the form of a new revision of the patch (series)
that just picks up the trailers and states that it's 1:1 the same otherwise.
Not a must, but in cases like here it would be definitively valid IMO.


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

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

end of thread, other threads:[~2025-02-11 12:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-25 13:09 [pve-devel] [PATCH container] fix #5907: ignore conflicting mount options for read-only mounts Filip Schauer
2024-11-28 13:42 ` Fiona Ebner
2024-11-28 14:56 ` Daniel Kral
2025-02-11 10:17 ` Fiona Ebner
2025-02-11 12:17   ` Thomas Lamprecht
2025-02-11 12:15 ` [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