I got this script named fork.sh:
#!/bin/sh
forkbomb() { forkbomb | forkbomb & } ; forkbomb
If I call it through suexec my whole system will consume 99% cpu. To prevent a normal bash forkbomb I used the limits.conf and set nproc to 50. This works as expected.
But if I call the above mentioned script through suexec over httpd, I see in top over 6000 tasks and a sys cpu use >97%. I can see multiple entries of user3 fork.sh with ~ 0,6% cpu. If I call systemd-cgtop the system.slice have 100% cpu and system.slice/httpd.service 75%
I restricted httpd with cgroups:
systemctl set-property --runtime httpd.service CPUShares=600 MemoryLimit=500M
I don't get it, why ulimits and cgroups will not handle this issue.
root
? Or are you going via root through suexec to run ashttp
? If it's the former: the problem is/etc/limit.d/90-nproc.conf
probably exists and does so for a good reason. If you restrict the number of processes runnable as root, you can essentially shut yourself out of the system.