linux, rootless: clamp oom_score_adj if it is too low

when running rootless, if the specified oom_score_adj for the
container process is lower than the current value, clamp it to the
current value and print a warning.

Closes: https://github.com/containers/podman/issues/19829

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano
2023-09-04 10:09:15 +02:00
parent 9bcab496e7
commit 8b4a79a744
3 changed files with 42 additions and 1 deletions

View File

@@ -939,6 +939,17 @@ EOF
is "$output" "$oomscore" "--oom-score-adj should override containers.conf"
}
# issue 19829
@test "rootless podman clamps oom-score-adj if it is lower than the current one" {
skip_if_not_rootless
skip_if_remote
if grep -- -1000 /proc/self/oom_score_adj; then
skip "the current oom-score-adj is already -1000"
fi
run_podman run --oom-score-adj=-1000 --rm $IMAGE true
is "$output" ".*Requested oom_score_adj=.* is lower than the current one, changing to .*"
}
# CVE-2022-1227 : podman top joins container mount NS and uses nsenter from image
@test "podman top does not use nsenter from image" {
keepid="--userns=keep-id"