Skip to content

Commit 6f0a3c5

Browse files
authored
Merge pull request #1875 from giuseppe/tag-1.24
NEWS: tag 1.24
2 parents ddc0953 + 5469320 commit 6f0a3c5

File tree

6 files changed

+100
-38
lines changed

6 files changed

+100
-38
lines changed

NEWS

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
* crun-1.24
2+
3+
- linux: add support for NUMA set_mempolicy.
4+
- intelrdt: add support for EnableMonitoring
5+
- linux: optimize masked paths with shared empty directory.
6+
- cgroup, systemd: validate the specified ebpf program is loaded by systemd.
7+
- krun: avoid failing if sev/nitro are not available.
8+
- linux: limit tmpfs memory usage for masked paths.
9+
- linux: fix regression mounting within userns. Detect when running inside a
10+
user namespace and treat the mounts in the same way as they would be treated
11+
with a new user namespace.
12+
- linux: never chown devices.
13+
114
* crun-1.23.1
215

316
- exec: fix a bug where the terminal could lose some bytes when

src/libcrun/criu.c

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,54 @@ criu_check_mem_track (char *work_path, libcrun_error_t *err)
267267

268268
# endif
269269

270+
static int
271+
register_masked_paths_mounts (runtime_spec_schema_config_schema *def, libcrun_container_t *container,
272+
struct libcriu_wrapper_s *libcriu_wrapper, bool is_restore, libcrun_error_t *err)
273+
{
274+
cleanup_free char *empty_dir_path = NULL;
275+
bool shared_dir_registered = false;
276+
size_t i;
277+
int ret;
278+
279+
for (i = 0; i < def->linux->masked_paths_len; i++)
280+
{
281+
struct stat statbuf;
282+
ret = stat (def->linux->masked_paths[i], &statbuf);
283+
if (ret != 0)
284+
continue;
285+
286+
if (S_ISDIR (statbuf.st_mode))
287+
{
288+
if (! shared_dir_registered)
289+
{
290+
ret = get_shared_empty_directory_path (&empty_dir_path,
291+
(container->context ? container->context->state_root : NULL), err);
292+
if (UNLIKELY (ret < 0))
293+
return ret;
294+
295+
ret = libcriu_wrapper->criu_add_ext_mount (empty_dir_path, empty_dir_path);
296+
if (UNLIKELY (ret < 0))
297+
return crun_make_error (err, -ret, "CRIU: failed adding external mount for shared empty directory `%s`", empty_dir_path);
298+
299+
shared_dir_registered = true;
300+
}
301+
302+
ret = libcriu_wrapper->criu_add_ext_mount (def->linux->masked_paths[i], empty_dir_path);
303+
if (UNLIKELY (ret < 0))
304+
return crun_make_error (err, -ret, "CRIU: failed adding external mount for masked directory `%s`", def->linux->masked_paths[i]);
305+
}
306+
else if (S_ISREG (statbuf.st_mode))
307+
{
308+
const char *bind_target = is_restore ? "/dev/null" : def->linux->masked_paths[i];
309+
ret = libcriu_wrapper->criu_add_ext_mount (def->linux->masked_paths[i], bind_target);
310+
if (UNLIKELY (ret < 0))
311+
return crun_make_error (err, -ret, "CRIU: failed adding external mount to `%s`", bind_target);
312+
}
313+
}
314+
315+
return 0;
316+
}
317+
270318
static int
271319
restore_cgroup_v1_mount (runtime_spec_schema_config_schema *def, libcrun_error_t *err)
272320
{
@@ -609,17 +657,9 @@ libcrun_container_checkpoint_linux_criu (libcrun_container_status_t *status, lib
609657
}
610658
}
611659

612-
for (i = 0; i < def->linux->masked_paths_len; i++)
613-
{
614-
struct stat statbuf;
615-
ret = stat (def->linux->masked_paths[i], &statbuf);
616-
if (ret == 0 && S_ISREG (statbuf.st_mode))
617-
{
618-
ret = libcriu_wrapper->criu_add_ext_mount (def->linux->masked_paths[i], def->linux->masked_paths[i]);
619-
if (UNLIKELY (ret < 0))
620-
return crun_make_error (err, -ret, "CRIU: failed adding external mount to `%s`", def->linux->masked_paths[i]);
621-
}
622-
}
660+
ret = register_masked_paths_mounts (def, container, libcriu_wrapper, false, err);
661+
if (UNLIKELY (ret < 0))
662+
return ret;
623663

624664
/* CRIU tries to checkpoint and restore all namespaces. However,
625665
* namespaces could be shared between containers in a pod.
@@ -947,17 +987,9 @@ libcrun_container_restore_linux_criu (libcrun_container_status_t *status, libcru
947987
}
948988
}
949989

950-
for (i = 0; i < def->linux->masked_paths_len; i++)
951-
{
952-
struct stat statbuf;
953-
ret = stat (def->linux->masked_paths[i], &statbuf);
954-
if (ret == 0 && S_ISREG (statbuf.st_mode))
955-
{
956-
ret = libcriu_wrapper->criu_add_ext_mount (def->linux->masked_paths[i], "/dev/null");
957-
if (UNLIKELY (ret < 0))
958-
return crun_make_error (err, -ret, "CRIU: failed adding external mount to `%s`", "/dev/null");
959-
}
960-
}
990+
ret = register_masked_paths_mounts (def, container, libcriu_wrapper, true, err);
991+
if (UNLIKELY (ret < 0))
992+
return ret;
961993

962994
/* do realpath on root */
963995
bundle_cleanup = realpath (status->bundle, NULL);

src/libcrun/linux.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,6 @@ get_shared_empty_dir_cached (libcrun_container_t *container, char **proc_fd_path
10871087
{
10881088
struct private_data_s *private_data = get_private_data (container);
10891089
cleanup_close int fd = -1;
1090-
cleanup_free char *run_dir = NULL;
10911090
cleanup_free char *empty_dir_path = NULL;
10921091
int ret;
10931092

@@ -1099,16 +1098,7 @@ get_shared_empty_dir_cached (libcrun_container_t *container, char **proc_fd_path
10991098
}
11001099

11011100
/* Slow path: create directory and cache everything once */
1102-
ret = get_run_directory (&run_dir, container->context->state_root, err);
1103-
if (UNLIKELY (ret < 0))
1104-
return ret;
1105-
1106-
ret = append_paths (&empty_dir_path, err, run_dir, ".empty-directory", NULL);
1107-
if (UNLIKELY (ret < 0))
1108-
return ret;
1109-
1110-
/* Ensure the empty directory exists (once per container) */
1111-
ret = crun_ensure_directory (empty_dir_path, 0555, false, err);
1101+
ret = get_shared_empty_directory_path (&empty_dir_path, container->context->state_root, err);
11121102
if (UNLIKELY (ret < 0))
11131103
return ret;
11141104

@@ -2674,7 +2664,9 @@ do_notify_socket (libcrun_container_t *container, const char *rootfs, libcrun_er
26742664
if (notify_socket == NULL)
26752665
return 0;
26762666

2677-
ret = libcrun_get_state_directory (&state_dir, container->context->state_root, container->context->id, err);
2667+
ret = libcrun_get_state_directory (&state_dir,
2668+
(container->context ? container->context->state_root : NULL),
2669+
container->context->id, err);
26782670
if (UNLIKELY (ret < 0))
26792671
return ret;
26802672

@@ -4637,7 +4629,9 @@ prepare_and_send_dev_mounts (libcrun_container_t *container, int sync_socket_hos
46374629
if (! has_userns || is_empty_string (container->context->id) || geteuid () > 0)
46384630
return send_mounts (sync_socket_host, dev_fds, how_many, def->linux->devices_len, err);
46394631

4640-
ret = libcrun_get_state_directory (&state_dir, container->context->state_root, container->context->id, err);
4632+
ret = libcrun_get_state_directory (&state_dir,
4633+
(container->context ? container->context->state_root : NULL),
4634+
container->context->id, err);
46414635
if (UNLIKELY (ret < 0))
46424636
return ret;
46434637

@@ -5909,7 +5903,7 @@ libcrun_configure_network (libcrun_container_t *container, libcrun_error_t *err)
59095903
else
59105904
{
59115905
struct nlmsghdr *hdr_recv;
5912-
char buf[sizeof (struct nlmsghdr) + sizeof (struct ifinfomsg)];
5906+
char buf[sizeof (struct nlmsghdr) + sizeof (struct nlmsgerr)];
59135907
struct sockaddr_nl addr = {
59145908
.nl_family = AF_NETLINK,
59155909
.nl_pid = getpid (),

src/libcrun/seccomp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ store_seccomp_cache (struct libcrun_seccomp_gen_ctx_s *ctx, libcrun_error_t *err
589589
if (is_empty_string (ctx->checksum))
590590
return 0;
591591

592-
dirfd = open_rundir_dirfd (container->context->state_root, err);
592+
dirfd = open_rundir_dirfd ((container->context ? container->context->state_root : NULL), err);
593593
if (UNLIKELY (dirfd < 0))
594594
return dirfd;
595595

@@ -874,7 +874,7 @@ libcrun_open_seccomp_bpf (struct libcrun_seccomp_gen_ctx_s *ctx, int *fd, libcru
874874
if (container == NULL || container->context == NULL)
875875
return crun_make_error (err, EINVAL, "invalid internal state");
876876

877-
dirfd = open_rundir_dirfd (container->context->state_root, err);
877+
dirfd = open_rundir_dirfd ((container->context ? container->context->state_root : NULL), err);
878878
if (UNLIKELY (dirfd < 0))
879879
return dirfd;
880880

src/libcrun/status.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,28 @@ get_run_directory (char **out, const char *state_root, libcrun_error_t *err)
8585
return 0;
8686
}
8787

88+
int
89+
get_shared_empty_directory_path (char **out, const char *state_root, libcrun_error_t *err)
90+
{
91+
cleanup_free char *run_dir = NULL;
92+
int ret;
93+
94+
ret = get_run_directory (&run_dir, state_root, err);
95+
if (UNLIKELY (ret < 0))
96+
return ret;
97+
98+
ret = append_paths (out, err, run_dir, ".empty-directory", NULL);
99+
if (UNLIKELY (ret < 0))
100+
return ret;
101+
102+
/* Ensure the empty directory exists */
103+
ret = crun_ensure_directory (*out, 0555, false, err);
104+
if (UNLIKELY (ret < 0))
105+
return ret;
106+
107+
return 0;
108+
}
109+
88110
int
89111
libcrun_get_state_directory (char **out, const char *state_root, const char *id, libcrun_error_t *err)
90112
{

src/libcrun/status.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ int libcrun_status_write_exec_fifo (const char *state_root, const char *id, libc
6565
int libcrun_status_has_read_exec_fifo (const char *state_root, const char *id, libcrun_error_t *err);
6666
int libcrun_check_pid_valid (libcrun_container_status_t *status, libcrun_error_t *err);
6767
int get_run_directory (char **out, const char *state_root, libcrun_error_t *err);
68+
int get_shared_empty_directory_path (char **out, const char *state_root, libcrun_error_t *err);
6869

6970
static inline void
7071
libcrun_free_container_listp (void *p)

0 commit comments

Comments
 (0)