From f8894bb3b5e679460133039ab1518fc1af9fac0c Mon Sep 17 00:00:00 2001 From: Ron Federman Date: Fri, 5 Jun 2026 23:21:08 +0300 Subject: [PATCH] rlimit: avoid performing the test and setting limit if its infinte Signed-off-by: Ron Federman --- rlimit/rlimit_linux.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rlimit/rlimit_linux.go b/rlimit/rlimit_linux.go index c8cada137..75d72b521 100644 --- a/rlimit/rlimit_linux.go +++ b/rlimit/rlimit_linux.go @@ -43,6 +43,12 @@ func detectMemcgAccounting() error { return fmt.Errorf("getting original memlock rlimit: %s", err) } + // If the soft limit is already infinite there is nothing for RemoveMemlock + // to do. + if oldLimit.Cur == unix.RLIM_INFINITY { + return nil + } + // Drop the current limit to zero, maintaining the old Max value. // This is always permitted by the kernel for unprivileged users. // Retrieve a new copy of the old limit tuple to minimize the chances