2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 01:51:51 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Andrei Vagin
a44aa6d985 criu: Version 4.1.1
This release of CRIU (4.1.1) addresses a critical compatibility issue
introduced in the Linux kernel and back-ported to all stable releases.

The kernel commit (12f147ddd6de "do_change_type(): refuse to operate on
unmounted/not ours mounts") addressed the security issue introduced
almost 20 years ago. Unfortunately, this change inadvertently broke the
restore functionality of mount namespaces within CRIU. Users attempting
to restore a container on updated kernels would encounter the error:
"mnt-v2: Failed to make mount 476 slave: Invalid argument."

This release contains the necessary adjustments to CRIU, allowing it to
work seamlessly with kernels incorporating this security change.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2025-07-29 09:10:08 -07:00
Andrei Vagin
ced15c302b test/zdtm: remove unused compiler argument
Fixes a clang compile-time error:
"argument unused during compilation: '-c'".

Signed-off-by: Andrei Vagin <avagin@google.com>
2025-07-29 09:10:08 -07:00
Andrei Vagin
570621a48a mount-v2: enter the mount namesapce to propagation properties
A kernel change (commit 12f147ddd6de, "do_change_type(): refuse to
operate on unmounted/not ours mounts") modified how mount propagation
properties can be changed. Previously, these properties could be changed
from any mount namespace. Now, they can only be modified from the
specific mount namespace where the target mount is actually mounted

This commit addresses this new restriction by ensuring that CRIU enters the
correct mount namespace before attempting to restore mount propagation
properties (MS_SLAVE or MS_SHARED) for a mount.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2025-07-29 09:10:08 -07:00
3 changed files with 27 additions and 14 deletions

View File

@ -2,7 +2,7 @@
# CRIU version.
CRIU_VERSION_MAJOR := 4
CRIU_VERSION_MINOR := 1
CRIU_VERSION_SUBLEVEL :=
CRIU_VERSION_SUBLEVEL := 1
CRIU_VERSION_EXTRA :=
CRIU_VERSION_NAME := CRISCV
CRIU_VERSION := $(CRIU_VERSION_MAJOR)$(if $(CRIU_VERSION_MINOR),.$(CRIU_VERSION_MINOR))$(if $(CRIU_VERSION_SUBLEVEL),.$(CRIU_VERSION_SUBLEVEL))$(if $(CRIU_VERSION_EXTRA),.$(CRIU_VERSION_EXTRA))

View File

@ -927,8 +927,12 @@ static int move_mount_set_group(int src_id, char *source, int dst_id)
static int restore_one_sharing(struct sharing_group *sg, struct mount_info *target)
{
int nsfd = -1, orig_nsfd = -1, exit_code = -1;
char target_path[PATH_MAX];
int target_fd;
int target_fd = -1;
if (!sg->master_id && !sg->shared_id)
return 0;
target_fd = fdstore_get(target->mnt_fd_id);
BUG_ON(target_fd < 0);
@ -943,8 +947,7 @@ static int restore_one_sharing(struct sharing_group *sg, struct mount_info *targ
first = get_first_mount(sg->parent);
if (move_mount_set_group(first->mnt_fd_id, NULL, target->mnt_fd_id)) {
pr_err("Failed to copy sharing from %d to %d\n", first->mnt_id, target->mnt_id);
close(target_fd);
return -1;
goto err;
}
} else {
/*
@ -956,16 +959,23 @@ static int restore_one_sharing(struct sharing_group *sg, struct mount_info *targ
*/
if (move_mount_set_group(-1, sg->source, target->mnt_fd_id)) {
pr_err("Failed to copy sharing from source %s to %d\n", sg->source, target->mnt_id);
close(target_fd);
return -1;
goto err;
}
}
}
nsfd = fdstore_get(target->nsid->mnt.nsfd_id);
if (nsfd < 0)
goto err;
if (switch_ns_by_fd(nsfd, &mnt_ns_desc, &orig_nsfd))
goto err;
if (sg->master_id) {
/* Convert shared_id to master_id */
if (mount(NULL, target_path, NULL, MS_SLAVE, NULL)) {
pr_perror("Failed to make mount %d slave", target->mnt_id);
close(target_fd);
return -1;
goto err;
}
}
@ -973,13 +983,16 @@ static int restore_one_sharing(struct sharing_group *sg, struct mount_info *targ
if (sg->shared_id) {
if (mount(NULL, target_path, NULL, MS_SHARED, NULL)) {
pr_perror("Failed to make mount %d shared", target->mnt_id);
close(target_fd);
return -1;
goto err;
}
}
close(target_fd);
return 0;
exit_code = 0;
err:
close_safe(&target_fd);
close_safe(&nsfd);
if (orig_nsfd >= 0 && restore_ns(orig_nsfd, &mnt_ns_desc))
exit_code = -1;
return exit_code;
}
static int restore_one_sharing_group(struct sharing_group *sg)

View File

@ -76,7 +76,7 @@ endef
%.d: %.c
$(E) " DEP " $@
$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -MM -MP -c $< -o $@
$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -MM -MP $< -o $@
%.o: %.c | %.d
$(E) " CC " $@