EAGAIN on fork, or adhering to cgroup pids.max setting - panics on fork bomb
- Dominant language
- Go
- Stars
- 19.3k
- Forks
- 2k
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 264
Description
Related: https://github.com/google/gvisor/issues/2489
According to cgroupsv1, fork might return EAGAIN: https://www.kernel.org/doc/Documentation/cgroup-v1/pids.txt
Runsc crashes in such case. To reproduce:
(1) Run runsc in a cgroup with pids.max set to low value (256?)
(2) Run this inside runsc
```
root@runsc:~# :(){ :|:& };:
[1] 12
```
This `:(){ :|:& };:` is a valid bash command, also known as fork bomb.
Runsc in `.boot` log shows a not-nice panic:
```
runtime: failed to create new OS thread (have 53 already; errno=11)
runtime: may need to increase max user processes (ulimit -u)
fatal error: newosproc
runtime stack:
runtime.throw(0xeed0c6, 0x9)
GOROOT/src/runtime/panic.go:1116 +0x72
runtime.newosproc(0xc0006d8380)
GOROOT/src/runtime/os_linux.go:161 +0x1ba
runtime.newm1(0xc0006d8380)
GOROOT/src/runtime/proc.go:1753 +0xdc
runtime.templateThread()
GOROOT/src/runtime/proc.go:1798 +0x71
runtime.mstart1()
GOROOT/src/runtime/proc.go:1097 +0xc3
runtime.mstart()
GOROOT/src/runtime/proc.go:1062 +0x6e
```
Another error I saw
```
panic: error initializing first thread: resource temporarily unavailable
goroutine 185 [running]:
gvisor.dev/gvisor/pkg/sentry/platform/ptrace.newSubprocess.func1(0xc000313440, 0xc00051bda0, 0xc00051be00)
pkg/sentry/platform/ptrace/subprocess.go:179 +0x335
created by gvisor.dev/gvisor/pkg/sentry/platform/ptrace.newSubprocess
pkg/sentry/platform/ptrace/subprocess.go:159 +0x13b
```
Runsc should not panic on a fork bomb, or when the user tries to launch too many pids.
Contributor guide
Assessment
This issue has not been assessed yet.