Bug 2225 - sshd core dumps when used in high scaled environments.
Summary: sshd core dumps when used in high scaled environments.
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 6.2p1
Hardware: All All
: P5 major
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_6_7
  Show dependency treegraph
 
Reported: 2014-04-12 13:41 AEST by kavitha
Modified: 2014-10-08 08:00 AEDT (History)
3 users (show)

See Also:


Attachments
possible fix. (688 bytes, text/plain)
2014-04-12 13:41 AEST, kavitha
dtucker: ok+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kavitha 2014-04-12 13:41:10 AEST
Created attachment 2424 [details]
possible fix.

sshd crashes with the core dump when used in high scale environment.
The program crashes inside the function "cleanup_exit" at line 

if (use_privsep && privsep_is_preauth && pmonitor->m_pid > 1)

It is always assumed here that pmonitor is always not NULL.
However pmonitor can be null, in the execution sequence below:


#0  0x0804e214 in cleanup_exit (i=255) at ../../../../../../src/crypto/openssh/sshd.c:2415
#1  0x080ae7bf in fatal (fmt=0x80b8ea6 "%s: socketpair: %s") at ../../../../../../src/crypto/openssh/fatal.c:42
#2  0x08065779 in monitor_openfds (mon=0x80eb5c0, do_logfds=1) at ../../../../../../src/crypto/openssh/monitor.c:1877
#3  0x080658ee in monitor_init () at ../../../../../../src/crypto/openssh/monitor.c:1903
#4  0x080507fd in privsep_preauth (authctxt=0x0) at ../../../../../../src/crypto/openssh/sshd.c:669
#5  0x08051f72 in main (ac=903248, av=0xc811cc00) at ../../../../../../src/crypto/openssh/sshd.c:2014


Here the pmonitor is NULL inside "privsep_preauth", which calls "monitor_init". "monitor_init" allocates memory for mon and calls "monitor_openfds"

However inside "monitor_openfds" the call to socketpair fails. (in our case with errno = 23 /* Too many open files in system */).

This calls "fatal" which in-turn calls "cleanup_exit".

Since pmonitor is not initialized until now, it crashes.
Comment 1 Damien Miller 2014-04-12 14:56:14 AEST
Patch applied - this will be in OpenSSH-6.7. Thanks!
Comment 2 Damien Miller 2014-10-08 08:00:21 AEDT
Close all bugs left open from 6.6 and 6.7 releases.