Repository navigation
exec: apply the process OOM score - #2425
Merged
Merged
Conversation
kolyshkin
force-pushed
the
set-oom-score-exec
branch
from
October 30, 2026 19:26
dfcf128 to
f92f999
Compare
The oomScoreAdj specified in the process passed to "crun exec" was ignored. Set it on crun itself before the dumpable flag is dropped, so that the exec process inherits it, as already done for the rlimits. Once crun is not dumpable, /proc/self/oom_score_adj is owned by root and cannot be written by rootless users. Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
If the exec process doesn't specify oomScoreAdj, use the value from the container configuration, as already done for other process attributes. Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
kolyshkin
force-pushed
the
set-oom-score-exec
branch
from
October 30, 2026 19:33
f92f999 to
f67cf17
Compare
kolyshkin
approved these changes
Oct 30, 2026
Collaborator
|
I took the liberty of removing the extra The change ( diff --git a/src/libcrun/container.c b/src/libcrun/container.c
index 2eeda861..e88619d5 100644
--- a/src/libcrun/container.c
+++ b/src/libcrun/container.c
@@ -4478,7 +4478,7 @@ libcrun_container_exec_with_options (libcrun_context_t *context, const char *id,
/* The exec process inherits it from us. This must be done before we drop
the dumpable flag, which makes /proc/self/oom_score_adj owned by root. */
- ret = libcrun_set_oom_score_adj (container, process, err);
+ ret = libcrun_set_oom (container, process, err);
if (UNLIKELY (ret < 0))
return ret;
diff --git a/src/libcrun/linux.c b/src/libcrun/linux.c
index 53cd59fe..6db4cc69 100644
--- a/src/libcrun/linux.c
+++ b/src/libcrun/linux.c
@@ -5307,8 +5307,8 @@ libcrun_set_domainname (libcrun_container_t *container, libcrun_error_t *err)
}
int
-libcrun_set_oom_score_adj (libcrun_container_t *container, runtime_spec_schema_config_schema_process *process,
- libcrun_error_t *err)
+libcrun_set_oom (libcrun_container_t *container, runtime_spec_schema_config_schema_process *process,
+ libcrun_error_t *err)
{
cleanup_close int fd = -1;
int ret;
@@ -5330,12 +5330,6 @@ libcrun_set_oom_score_adj (libcrun_container_t *container, runtime_spec_schema_c
return 0;
}
-int
-libcrun_set_oom (libcrun_container_t *container, libcrun_error_t *err)
-{
- return libcrun_set_oom_score_adj (container, container->container_def->process, err);
-}
-
const char *sysctlRequiringIPC[] = {
"kernel/msgmax",
"kernel/msgmnb",
@@ -6828,7 +6822,7 @@ init_container (libcrun_container_t *container, int sync_socket_container, struc
return ret;
}
- ret = libcrun_set_oom (container, err);
+ ret = libcrun_set_oom (container, container->container_def->process, err);
if (UNLIKELY (ret < 0))
return ret;
@@ -7131,7 +7125,7 @@ libcrun_run_linux_container (libcrun_container_t *container, container_entrypoin
return ret;
}
- ret = libcrun_set_oom (container, err);
+ ret = libcrun_set_oom (container, container->container_def->process, err);
if (UNLIKELY (ret < 0))
return ret;
diff --git a/src/libcrun/linux.h b/src/libcrun/linux.h
index 926ca413..bd7f71f6 100644
--- a/src/libcrun/linux.h
+++ b/src/libcrun/linux.h
@@ -81,9 +81,8 @@ int libcrun_set_selinux_label (libcrun_container_t *container, runtime_spec_sche
int libcrun_set_apparmor_profile (libcrun_container_t *container, runtime_spec_schema_config_schema_process *proc, bool now, libcrun_error_t *err);
int libcrun_set_hostname (libcrun_container_t *container, libcrun_error_t *err);
int libcrun_set_domainname (libcrun_container_t *container, libcrun_error_t *err);
-int libcrun_set_oom (libcrun_container_t *container, libcrun_error_t *err);
-int libcrun_set_oom_score_adj (libcrun_container_t *container, runtime_spec_schema_config_schema_process *process,
- libcrun_error_t *err);
+int libcrun_set_oom (libcrun_container_t *container, runtime_spec_schema_config_schema_process *process,
+ libcrun_error_t *err);
int libcrun_set_sysctl (libcrun_container_t *container, libcrun_error_t *err);
int libcrun_set_terminal (libcrun_container_t *container, libcrun_error_t *err);
int libcrun_join_process (libcrun_context_t *context, libcrun_container_t *container, pid_t pid_to_join, |
kolyshkin
enabled auto-merge
October 30, 2026 19:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to: #2424