Добро пожаловать, Гость

ТЕМА: Memory leak in OpenSSH Server for Windows/Cygwin

Memory leak in OpenSSH Server for Windows/Cygwin 22 нояб 2013 11:42 #73

  • Олегатор
  • Олегатор аватар
  • Не в сети
Утечка памяти через OpenSSH сервер Release 6.4p1 для ОС Windows, который работает в среде Cygwin. Использовалось ПО:
  • Cygwin latest (Cygwin DLL is 1.7.25)
  • cygrunsrv V1.50, Oct 30 2013
  • OpenSSH 6.4p1
  • Windows XP SP3
  • FileZilla 3.7.3
OpenSSH 6.4p1 (http://www.openssh.com/portable.html) был скомпилирован в такой конфигурации:
OpenSSH has been configured with the following options:
                     User binaries: /bin
                   System binaries: /sbin
               Configuration files: /etc/ssh
                   Askpass program: /usr/sbin/ssh-askpass
                      Manual pages: /share/man/manX
                          PID file: /var/run
  Privilege separation chroot path: /var/empty
            sshd default user PATH: /bin:/usr/sbin:/sbin
                    Manpage format: doc
                       PAM support: yes
                   OSF SIA support: no
                 KerberosV support: no
                   SELinux support: no
                 Smartcard support:
                     S/KEY support: no
              TCP Wrappers support: yes
              MD5 password support: yes
                   libedit support: no
  Solaris process contract support: no
           Solaris project support: no
       IP address in $DISPLAY hack: yes
           Translate v4 in v6 hack: yes
                  BSD Auth support: no
              Random number source: OpenSSL internal ONLY
             Privsep sandbox style: rlimit
 
              Host: i686-pc-cygwin
          Compiler: gcc
    Compiler flags: -g -O2 -Wall -Wpointer-arith -Wuninitialized \
        -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign \
        -Wno-unused-result -fno-strict-aliasing -D_FORTIFY_SOURCE=2 \
        -fno-builtin-memset -fstack-protector-all

При использовании FileZilla 3.7.3, подключившись к OpenSSH (Release 6.4p1) хосту (Windows XP SP3) на нём открывается один процесс sshd.exe и один sftp-server.exe, но после отключения FileZilla они (sshd.exe и sftp-server.exe) продолжают висеть в списке процессов - они не умирают даже после полной остановки сервиса и требуют ручного убивания через диспетчер задач!

Если мы несколько раз (3-10) подключимся и отключимся к OpenSSH с помощью FileZilla то в итоге получим кучу зависших процессов sshd.exe и sftp-server.exe, что чревато утечкой оперативной памяти и как результат отказом в обслуживании!

Шаг 1 - Старт сервиса "OpenSSH Server"

После запуска "OpenSSH Server for Windows":



Шаг 2 Подключение/отключение к "OpenSSH Server"

После подключения с последующим отключением к "OpenSSH Server for Windows" с помощью FileZilla получаем по одному зависшему процесу sshd.exe и sftp-server.exe:





Результат

Повторив подключение/отключение к "OpenSSH Server for Windows" с помощью FileZilla около 10 раз получаем целую кучу зависших процессов sshd.exe и sftp-server.exe:



В итоге имеем утечку памяти через "OpenSSH Server for Windows". Проблема замечена только при использовании FileZilla, ещё с версии "OpenSSH for Windows 3.81p1-1 / 9 July 2004" и продолжает присутствовать в текущих версиях "OpenSSH for Windows".

Процессы sshd.exe и sftp-server.exe не умирают даже после полной остановки сервиса "OpenSSH Server", выключения FileZilla или закрытия 22 порта брандмауэром - sshd.exe и sftp-server.exe требуют только ручного убивания!!!

Уже готовый бинарный пакет "openssh: The OpenSSH server and client programs (installed binaries and support files)": http://cygwin.com/cgi-bin2/package-cat.cgi?file=x86%2Fopenssh%2Fopenssh-6.4p1-1&grep=openssh - страдает теми же ошибками!
Юрист, программист, спортсмен, бизнесмен и просто красавец.
Последнее редактирование: 23 нояб 2013 10:12 от Олегатор.
Администратор запретил публиковать записи гостям.

Memory leak in OpenSSH Server for Windows/Cygwin 24 нояб 2013 14:47 #75

  • Иван Шаман
  • Иван Шаман аватар
  • Не в сети
Значит читаем "man sshd_config":
ClientAliveCountMax
        Sets the number of client alive messages (see below) which may be
        sent without sshd(8) receiving any messages back from the client.
        If this threshold is reached while client alive messages are
        being sent, sshd will disconnect the client, terminating the ses-
        sion.  It is important to note that the use of client alive mes-
        sages is very different from TCPKeepAlive (below).  The client
        alive messages are sent through the encrypted channel and there-
        fore will not be spoofable.  The TCP keepalive option enabled by
        TCPKeepAlive is spoofable.  The client alive mechanism is valu-
        able when the client or server depend on knowing when a connec-
        tion has become inactive.

        The default value is 3.  If ClientAliveInterval (see below) is
        set to 15, and ClientAliveCountMax is left at the default, unre-
        sponsive SSH clients will be disconnected after approximately 45
        seconds.  This option applies to protocol version 2 only.

ClientAliveInterval
        Sets a timeout interval in seconds after which if no data has
        been received from the client, sshd(8) will send a message
        through the encrypted channel to request a response from the
        client.  The default is 0, indicating that these messages will
        not be sent to the client.  This option applies to protocol ver-
        sion 2 only.
Потом в /etc/ssh/sshd_config делаем так:
ClientAliveInterval 3
ClientAliveCountMax 3
В данном случае клиент будет отключен через 9 сек. не активности. Т.е. через 9 сек. дочерние процессы sshd.exe и sftp-server.exe будут убиты - проверено лично!
Меня нет ни в Инстаграмме ни в Фейсбуке, я просто хожу по улицам и рассказываю первым встречным: сколько зарабатываю; с кем дружу; где живу и чем дышу. У меня даже появилось несколько подписчиков: ПСИХоЛОХ и участковый полицай!
Администратор запретил публиковать записи гостям.

Memory leak in OpenSSH Server for Windows/Cygwin 30 нояб 2013 11:57 #80

  • Арсений Яковлевич
  • Арсений Яковлевич аватар
  • Не в сети
Проверил с настройками по умолчанию, т.е. без:
ClientAliveInterval 3
ClientAliveCountMax 3
Процессы дохнут сами, но правда только примерно аж часа через 3.
Администратор запретил публиковать записи гостям.
Комментарии в блоге