<div dir="ltr"><div dir="ltr">On Wed, Aug 12, 2020 at 7:03 AM Tomasz Chmielewski <<a href="mailto:mangoo@wpkg.org">mangoo@wpkg.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I've made a mistake and have executed a forkbomb-like task. Almost <br>
immediately, the system became unresponsive, ssh session froze or were <br>
very slow to output even single characters; some ssh sessions timed out <br>
and were disconnected.<br>
<br>
It was not possible to connect a new ssh session to interrupt the <br>
runaway task - new connection attempt were simply timing out.<br>
<br>
SSH is the only way to access the server. Eventually, after some 30 <br>
mins, the system "unfroze" - but - I wonder - can systemd help sysadmins <br>
getting out of such situations?<br>
<br>
I realize it's a bit tricky, as there are two cases here:<br>
<br>
1) misbehaving program is a child process of sshd (i.e. user logged in <br>
and executed a forkbomb)<br></blockquote><div><br></div><div>I don't think "child process of sshd" is the useful part, as logged-in user processes are actually moved to a separate cgroup for the session – so yes, they're sshd children, but they actually have resource limits fully separate from the main sshd daemon process.</div><div><br></div><div>Which means that with systemd, each user already has their own limit on the number of processes/tasks (the default in user-.slice.d is TasksMax=33% of...something, but it could be lowered to e.g. 10% or to 4096) without affecting the service itself.</div><div><br></div><div>So I'm sure that sshd.service and user-0.slice could be tweaked somehow to give root a higher priority at cgroup level, but that depends on what your system actually ran out of...</div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Mantas Mikulėnas</div></div></div>