All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.2] fs: forbid freezing and thawing file systems from a Container
@ 2026-11-17 13:59 Vasileios Almpanis
  2026-11-17 14:02 ` no-reply
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Vasileios Almpanis @ 2026-11-17 13:59 UTC (permalink / raw)
  To: Konstantin Khorenko; +Cc: devel

A Container can freeze a file system it mounted itself, since
ioctl_fsfreeze() and ioctl_fsthaw() only check CAP_SYS_ADMIN in
s_user_ns. That is a bad thing to allow:

  * Processes on top of a frozen file system hang in the kernel, so
    CRIU can neither ptrace attach nor freeze them and the checkpoint
    fails.
  * CRIU does not dump the frozen state anyway, so after restore the
    file system comes back thawed although it was frozen on the source.

Nothing vital inside a Container is known to need it, and most file
systems a Container sees are not freezable at all. So keep the
existing check and return EPERM for FIFREEZE and FITHAW when called
from a Container.

https://virtuozzo.atlassian.net/browse/VSTOR-155592

Feature: ve: allow various syscalls in CT root userns
Suggested-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
 fs/ioctl.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/ioctl.c b/fs/ioctl.c
index d8b2c630cb3e..1927a10ad8a0 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -22,6 +22,7 @@
 #include <linux/mount.h>
 #include <linux/fscrypt.h>
 #include <linux/fileattr.h>
+#include <linux/ve.h>
 
 #include "internal.h"
 
@@ -394,7 +395,8 @@ static int ioctl_fsfreeze(struct file *filp)
 {
 	struct super_block *sb = file_inode(filp)->i_sb;
 
-	if (!ns_capable(sb->s_user_ns, CAP_SYS_ADMIN))
+	if (!ve_is_super(get_exec_env()) ||
+	    !ns_capable(sb->s_user_ns, CAP_SYS_ADMIN))
 		return -EPERM;
 
 	/* If filesystem doesn't support freeze feature, return. */
@@ -411,7 +413,8 @@ static int ioctl_fsthaw(struct file *filp)
 {
 	struct super_block *sb = file_inode(filp)->i_sb;
 
-	if (!ns_capable(sb->s_user_ns, CAP_SYS_ADMIN))
+	if (!ve_is_super(get_exec_env()) ||
+	    !ns_capable(sb->s_user_ns, CAP_SYS_ADMIN))
 		return -EPERM;
 
 	/* Thaw */

---
base-commit: a656d0a24ddd1939d7deea2f7450873e662c828e
change-id: 20261117-ct-fsfreeze-7e16ba48a545

-- 
Best regards, Vasileios Almpanis
Software Developer, Virtuozzo.

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* Re: [Devel] [PATCH hci-8.2] fs: forbid freezing and thawing file systems from a Container
  2026-11-17 13:59 [Devel] [PATCH hci-8.2] fs: forbid freezing and thawing file systems from a Container Vasileios Almpanis
@ 2026-11-17 14:02 ` no-reply
  2026-11-17 14:08 ` Pavel Tikhomirov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: no-reply @ 2026-11-17 14:02 UTC (permalink / raw)
  To: Vasileios Almpanis, Konstantin Khorenko; +Cc: devel

> A Container can freeze a file system it mounted itself, since
> ioctl_fsfreeze() and ioctl_fsthaw() only check CAP_SYS_ADMIN in
> s_user_ns. That is a bad thing to allow:
> 
>   * Processes on top of a frozen file system hang in the kernel, so
>     CRIU can neither ptrace attach nor freeze them and the checkpoint
>     fails.
>   * CRIU does not dump the frozen state anyway, so after restore the
>     file system comes back thawed although it was frozen on the source.
> 
> Nothing vital inside a Container is known to need it, and most file
> systems a Container sees are not freezable at all. So keep the
> existing check and return EPERM for FIFREEZE and FITHAW when called
> from a Container.
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-155592
> 
> Feature: ve: allow various syscalls in CT root userns
> Suggested-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117-ct-fsfreeze-v1-1-23272094ba36@virtuozzo.com?part=1


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* Re: [Devel] [PATCH hci-8.2] fs: forbid freezing and thawing file systems from a Container
  2026-11-17 13:59 [Devel] [PATCH hci-8.2] fs: forbid freezing and thawing file systems from a Container Vasileios Almpanis
  2026-11-17 14:02 ` no-reply
@ 2026-11-17 14:08 ` Pavel Tikhomirov
  2026-11-17 14:55 ` Konstantin Khorenko
  2026-11-17 14:55 ` Konstantin Khorenko
  3 siblings, 0 replies; 5+ messages in thread
From: Pavel Tikhomirov @ 2026-11-17 14:08 UTC (permalink / raw)
  To: Vasileios Almpanis; +Cc: devel

On Tue, 17 Nov 2026 13:59:28 +0000, Vasileios Almpanis <vasileios.almpanis@virtuozzo.com> wrote:
> A Container can freeze a file system it mounted itself, since
> ioctl_fsfreeze() and ioctl_fsthaw() only check CAP_SYS_ADMIN in
> s_user_ns. That is a bad thing to allow:
> 
>   * Processes on top of a frozen file system hang in the kernel, so
>     CRIU can neither ptrace attach nor freeze them and the checkpoint
>     fails.
>   * CRIU does not dump the frozen state anyway, so after restore the
>     file system comes back thawed although it was frozen on the source.
> 
> [...]

Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>

-- 
Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* Re: [Devel] [PATCH hci-8.2] fs: forbid freezing and thawing file systems from a Container
  2026-11-17 13:59 [Devel] [PATCH hci-8.2] fs: forbid freezing and thawing file systems from a Container Vasileios Almpanis
  2026-11-17 14:02 ` no-reply
  2026-11-17 14:08 ` Pavel Tikhomirov
@ 2026-11-17 14:55 ` Konstantin Khorenko
  2026-11-17 14:55 ` Konstantin Khorenko
  3 siblings, 0 replies; 5+ messages in thread
From: Konstantin Khorenko @ 2026-11-17 14:55 UTC (permalink / raw)
  To: Vasileios Almpanis; +Cc: devel

Applying with these fixes on my side:
- "CRIU can neither ptrace attach nor freeze them" -> "CRIU can
  neither stop them under ptrace nor freeze them": PTRACE_SEIZE
  itself succeeds, the task just never stops
- "most file systems a Container sees are not freezable at all" ->
  "the only file systems a Container can freeze are ext4 and XFS it
  mounted itself": the root disk is ext4 too, it is only mounted by
  the host

On Tue, 17 Nov 2026 13:59:28 +0000, Vasileios Almpanis wrote:
> Nothing vital inside a Container is known to need it, and most file
> systems a Container sees are not freezable at all. So keep the
> existing check and return EPERM for FIFREEZE and FITHAW when called
> from a Container.

One more reason, no need to add it: before this patch a Container
could also FITHAW a file system mounted inside it while the host held
it frozen, e.g. during a dm suspend with lockfs for a snapshot.

A heads-up for tests: LTP df01 calls tst_fsfreeze on xfs. Where a test
suite runs it inside a Container on xfs, it now gets EPERM there.

Thanks.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* Re: [Devel] [PATCH hci-8.2] fs: forbid freezing and thawing file systems from a Container
  2026-11-17 13:59 [Devel] [PATCH hci-8.2] fs: forbid freezing and thawing file systems from a Container Vasileios Almpanis
                   ` (2 preceding siblings ...)
  2026-11-17 14:55 ` Konstantin Khorenko
@ 2026-11-17 14:55 ` Konstantin Khorenko
  3 siblings, 0 replies; 5+ messages in thread
From: Konstantin Khorenko @ 2026-11-17 14:55 UTC (permalink / raw)
  To: Vasileios Almpanis; +Cc: devel

On Tue, 17 Nov 2026 13:59:28 +0000, Vasileios Almpanis wrote:
> fs: forbid freezing and thawing file systems from a Container

Applied to branch-rh10-6.12.0-211.75.1.26.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.24.3.vz10, thanks!

[1/1] fs: forbid freezing and thawing file systems from a Container
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/57611c10306f

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

end of thread, other threads:[~2026-11-17 14:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 13:59 [Devel] [PATCH hci-8.2] fs: forbid freezing and thawing file systems from a Container Vasileios Almpanis
2026-11-17 14:02 ` no-reply
2026-11-17 14:08 ` Pavel Tikhomirov
2026-11-17 14:55 ` Konstantin Khorenko
2026-11-17 14:55 ` Konstantin Khorenko

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.