Bug 3489 - "MaxStartups 0" passes "sshd -t", but a configuration reload dies the server
Summary: "MaxStartups 0" passes "sshd -t", but a configuration reload dies the server
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 9.1p1
Hardware: Other Linux
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_9_2
  Show dependency treegraph
 
Reported: 2022-10-24 06:56 AEDT by Petr Pisar
Modified: 2023-03-17 13:42 AEDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Pisar 2022-10-24 06:56:52 AEDT
I tried disabling MaxStartups feature (disabling is not documented in a manual) in openssh-9.1_p1 with setting:

MaxStartups 0

"sshd -t" command did not report any errors. So I sent SIGHUP to the deamon to reload the configuration, and then I tried to ssh-login to the machine and I found I cannot connect it.

I assumed 0 was interpreted as no connections allowed, thus I reverted the change in sshd configuration file, sent SIGHUP signal again, and my init (OpenRC) system reported the daemon is not running. It was obvious the sshd daemon "crashed".

A system log contains:

Oct 23 21:18:48 router start-stop-daemon[23658]: Will stop PID 3640
Oct 23 21:18:48 router start-stop-daemon[23658]: Sending signal 1 to PID 3640
Oct 23 21:18:48 router sshd[3640]: Received SIGHUP; restarting.
Oct 23 21:18:49 router sshd[3640]: Server listening on 0.0.0.0 port 22.
Oct 23 21:18:49 router sshd[3640]: Server listening on :: port 22.
Oct 23 21:18:49 router sshd[3640]: fatal: xcalloc: zero size
Oct 23 21:19:14 router start-stop-daemon[23691]: Will stop PID 3640
Oct 23 21:19:14 router /etc/init.d/sshd[23691]: start-stop-daemon: no matching processes found

The "fatal: xcalloc: zero size" message explains the "crash". The server attempted to allocate a memory for 0 MaxStartups connections, 0 was rejected as in invalid size by an allocator and the daemon terminated.

Could you please patch "sshd -t" code path to reject "MaxStartups 0" configuration line?
Comment 1 Darren Tucker 2022-11-07 22:26:31 AEDT
Fixed in this commit, which will be in 9.2:
https://github.com/openssh/openssh-portable/commit/1d78d25653805aefc7a8dd9d86cd7359ada3823c

Thanks for the report.
Comment 2 Damien Miller 2023-03-17 13:42:10 AEDT
OpenSSH 9.3 has been released. Close resolved bugs