From 44483133fd991ec929fb1404e087d08f679c8d28 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 21 Aug 2024 13:43:42 -0700 Subject: syscall: honor prlimit set by a different process On Linux one process can call prlimit to change the resource limit of another process. With this change we treat that as though the current process called prlimit (or setrlimit) to set its own limit. The cost is one additional getrlimit system call per fork/exec, for cases in which the rlimit Cur and Max values differ at startup. This revealed a bug: the setrlimit (not Setrlimit) function should not change the cached rlimit. That means that it must call prlimit1, not prlimit. Fixes #66797 Change-Id: I46bfd06e09ab7273fe8dd9b5b744dffdf31d828b Reviewed-on: https://go-review.googlesource.com/c/go/+/607516 Auto-Submit: Ian Lance Taylor Reviewed-by: Damien Neil Reviewed-by: Ian Lance Taylor Reviewed-by: Aleksa Sarai Reviewed-by: Kirill Kolyshkin LUCI-TryBot-Result: Go LUCI Auto-Submit: Ian Lance Taylor --- src/syscall/syscall_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/syscall/syscall_linux.go') diff --git a/src/syscall/syscall_linux.go b/src/syscall/syscall_linux.go index 1fe422d691..003f7a538c 100644 --- a/src/syscall/syscall_linux.go +++ b/src/syscall/syscall_linux.go @@ -1296,7 +1296,7 @@ func Getrlimit(resource int, rlim *Rlimit) (err error) { // setrlimit sets a resource limit. // The Setrlimit function is in rlimit.go, and calls this one. func setrlimit(resource int, rlim *Rlimit) (err error) { - return prlimit(0, resource, rlim, nil) + return prlimit1(0, resource, rlim, nil) } // prlimit changes a resource limit. We use a single definition so that -- cgit v1.3