[openssh] Fixes ASAN memory leak errors

Fixes the two memory leak errors that ASAN found in openssh-portable:

- one, a global variable is never freed.  Handled by registering an
  atexit().

- two, a local array took ownership of a pointer to a string that is
  then never freed.  Handled by registering a cleanup attribute, because
  there are multiple return paths from the function, and this change is
  made locally so we know our compiler supports the cleanup approach.

Hopefully this makes ASAN happier.

The fix is made in our fork of openssh-portable because:

- The local variable fix is compiler-dependent, so may not be applicable
  in general to the upstream.

- Upstream seems to not care about issues like these, otherwise they'd
  have long handled it.

Bug: 56434
Change-Id: I3139279fe9c8fde2e146561b47b632af52916bdb
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/openssh-portable/+/462755
Reviewed-by: George Kulakowski <kulakowski@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Fuchsia-Auto-Submit: Filip Filmar <fmil@google.com>
1 file changed
tree: abfdc55388087bf35d9ed1d843ee0ba76de2bb47
  1. contrib/
  2. fuchsia/
  3. openbsd-compat/
  4. regress/
  5. .depend
  6. .gitignore
  7. .skipped-commit-ids
  8. aclocal.m4
  9. addrmatch.c
  10. atomicio.c
  11. atomicio.h
  12. audit-bsm.c
  13. audit-linux.c
  14. audit.c
  15. audit.h
  16. auth-bsdauth.c
  17. auth-krb5.c
  18. auth-options.c
  19. auth-options.h
  20. auth-pam.c
  21. auth-pam.h
  22. auth-passwd.c
  23. auth-rhosts.c
  24. auth-shadow.c
  25. auth-sia.c
  26. auth-sia.h
  27. auth.c
  28. auth.h
  29. auth2-chall.c
  30. auth2-gss.c
  31. auth2-hostbased.c
  32. auth2-kbdint.c
  33. auth2-none.c
  34. auth2-passwd.c
  35. auth2-pubkey.c
  36. auth2.c
  37. authfd.c
  38. authfd.h
  39. authfile.c
  40. authfile.h
  41. bitmap.c
  42. bitmap.h
  43. BUILD.gn
  44. buildpkg.sh.in
  45. canohost.c
  46. canohost.h
  47. chacha.c
  48. chacha.h
  49. channels.c
  50. channels.h
  51. cipher-aes.c
  52. cipher-aesctr.c
  53. cipher-aesctr.h
  54. cipher-chachapoly.c
  55. cipher-chachapoly.h
  56. cipher-ctr.c
  57. cipher.c
  58. cipher.h
  59. cleanup.c
  60. clientloop.c
  61. clientloop.h
  62. compat.c
  63. compat.h
  64. configure.ac
  65. CREDITS
  66. crypto_api.h
  67. defines.h
  68. dh.c
  69. dh.h
  70. digest-libc.c
  71. digest-openssl.c
  72. digest.h
  73. dispatch.c
  74. dispatch.h
  75. dns.c
  76. dns.h
  77. ed25519.c
  78. entropy.c
  79. entropy.h
  80. fatal.c
  81. fe25519.c
  82. fe25519.h
  83. fixalgorithms
  84. fixpaths
  85. ge25519.c
  86. ge25519.h
  87. ge25519_base.data
  88. groupaccess.c
  89. groupaccess.h
  90. gss-genr.c
  91. gss-serv-krb5.c
  92. gss-serv.c
  93. hash.c
  94. hmac.c
  95. hmac.h
  96. hostfile.c
  97. hostfile.h
  98. includes.h
  99. INSTALL
  100. install-sh
  101. kex.c
  102. kex.h
  103. kexc25519.c
  104. kexdh.c
  105. kexecdh.c
  106. kexgen.c
  107. kexgex.c
  108. kexgexc.c
  109. kexgexs.c
  110. kexsntrup4591761x25519.c
  111. krl.c
  112. krl.h
  113. LICENCE
  114. log.c
  115. log.h
  116. loginrec.c
  117. loginrec.h
  118. logintest.c
  119. mac.c
  120. mac.h
  121. Makefile.in
  122. match.c
  123. match.h
  124. md5crypt.c
  125. md5crypt.h
  126. mdoc2man.awk
  127. misc.c
  128. misc.h
  129. mkinstalldirs
  130. moduli
  131. moduli.5
  132. moduli.c
  133. monitor.c
  134. monitor.h
  135. monitor_fdpass.c
  136. monitor_fdpass.h
  137. monitor_wrap.c
  138. monitor_wrap.h
  139. msg.c
  140. msg.h
  141. mux.c
  142. myproposal.h
  143. nchan.c
  144. nchan.ms
  145. nchan2.ms
  146. openssh.xml.in
  147. opensshd.init.in
  148. OVERVIEW
  149. packet.c
  150. packet.h
  151. pathnames.h
  152. pkcs11.h
  153. platform-misc.c
  154. platform-pledge.c
  155. platform-tracing.c
  156. platform.c
  157. platform.h
  158. poly1305.c
  159. poly1305.h
  160. progressmeter.c
  161. progressmeter.h
  162. PROTOCOL
  163. PROTOCOL.agent
  164. PROTOCOL.certkeys
  165. PROTOCOL.chacha20poly1305
  166. PROTOCOL.key
  167. PROTOCOL.krl
  168. PROTOCOL.mux
  169. PROTOCOL.sshsig
  170. PROTOCOL.u2f
  171. readconf.c
  172. readconf.h
  173. README
  174. README.dns
  175. README.fuchsia
  176. README.md
  177. README.platform
  178. README.privsep
  179. README.tun
  180. readpass.c
  181. regen.sh
  182. rijndael.c
  183. rijndael.h
  184. sandbox-capsicum.c
  185. sandbox-darwin.c
  186. sandbox-null.c
  187. sandbox-pledge.c
  188. sandbox-rlimit.c
  189. sandbox-seccomp-filter.c
  190. sandbox-solaris.c
  191. sandbox-systrace.c
  192. sc25519.c
  193. sc25519.h
  194. scp.1
  195. scp.c
  196. servconf.c
  197. servconf.h
  198. serverloop.c
  199. serverloop.h
  200. session.c
  201. session.h
  202. sftp-client.c
  203. sftp-client.h
  204. sftp-common.c
  205. sftp-common.h
  206. sftp-glob.c
  207. sftp-realpath.c
  208. sftp-server-main.c
  209. sftp-server.8
  210. sftp-server.c
  211. sftp.1
  212. sftp.c
  213. sftp.h
  214. sk-api.h
  215. sk-usbhid.c
  216. smult_curve25519_ref.c
  217. sntrup4591761.c
  218. sntrup4591761.sh
  219. ssh-add.1
  220. ssh-add.c
  221. ssh-agent.1
  222. ssh-agent.c
  223. ssh-dss.c
  224. ssh-ecdsa-sk.c
  225. ssh-ecdsa.c
  226. ssh-ed25519-sk.c
  227. ssh-ed25519.c
  228. ssh-gss.h
  229. ssh-keygen.1
  230. ssh-keygen.c
  231. ssh-keyscan.1
  232. ssh-keyscan.c
  233. ssh-keysign.8
  234. ssh-keysign.c
  235. ssh-pkcs11-client.c
  236. ssh-pkcs11-helper.8
  237. ssh-pkcs11-helper.c
  238. ssh-pkcs11.c
  239. ssh-pkcs11.h
  240. ssh-rsa.c
  241. ssh-sandbox.h
  242. ssh-sk-client.c
  243. ssh-sk-helper.8
  244. ssh-sk-helper.c
  245. ssh-sk.c
  246. ssh-sk.h
  247. ssh-xmss.c
  248. ssh.1
  249. ssh.c
  250. ssh.h
  251. ssh2.h
  252. ssh_api.c
  253. ssh_api.h
  254. ssh_config
  255. ssh_config.5
  256. sshbuf-getput-basic.c
  257. sshbuf-getput-crypto.c
  258. sshbuf-io.c
  259. sshbuf-misc.c
  260. sshbuf.c
  261. sshbuf.h
  262. sshconnect.c
  263. sshconnect.h
  264. sshconnect2.c
  265. sshd.8
  266. sshd.c
  267. sshd_config
  268. sshd_config.5
  269. ssherr.c
  270. ssherr.h
  271. sshkey-xmss.c
  272. sshkey-xmss.h
  273. sshkey.c
  274. sshkey.h
  275. sshlogin.c
  276. sshlogin.h
  277. sshpty.c
  278. sshpty.h
  279. sshsig.c
  280. sshsig.h
  281. sshtty.c
  282. survey.sh.in
  283. TODO
  284. ttymodes.c
  285. ttymodes.h
  286. uidswap.c
  287. uidswap.h
  288. umac.c
  289. umac.h
  290. umac128.c
  291. utf8.c
  292. utf8.h
  293. verify.c
  294. version.h
  295. xmalloc.c
  296. xmalloc.h
  297. xmss_commons.c
  298. xmss_commons.h
  299. xmss_fast.c
  300. xmss_fast.h
  301. xmss_hash.c
  302. xmss_hash.h
  303. xmss_hash_address.c
  304. xmss_hash_address.h
  305. xmss_wots.c
  306. xmss_wots.h
README.md

Portable OpenSSH

Fuzzing Status

OpenSSH is a complete implementation of the SSH protocol (version 2) for secure remote login, command execution and file transfer. It includes a client ssh and server sshd, file transfer utilities scp and sftp as well as tools for key generation (ssh-keygen), run-time key storage (ssh-agent) and a number of supporting programs.

This is a port of OpenBSD's OpenSSH to most Unix-like operating systems, including Linux, OS X and Cygwin. Portable OpenSSH polyfills OpenBSD APIs that are not available elsewhere, adds sshd sandboxing for more operating systems and includes support for OS-native authentication and auditing (e.g. using PAM).

Documentation

The official documentation for OpenSSH are the man pages for each tool:

Stable Releases

Stable release tarballs are available from a number of download mirrors. We recommend the use of a stable release for most users. Please read the release notes for details of recent changes and potential incompatibilities.

Building Portable OpenSSH

Dependencies

Portable OpenSSH is built using autoconf and make. It requires a working C compiler, standard library and headers, and zlib. libcrypto from either LibreSSL or OpenSSL may also be used, but OpenSSH may be built without it supporting a subset of crypto algorithms.

FIDO security token support need libfido2 and its dependencies. Also, certain platforms and build-time options may require additional dependencies, see README.platform for details.

Building a release

Releases include a pre-built copy of the configure script and may be built using:

tar zxvf openssh-X.YpZ.tar.gz
cd openssh
./configure # [options]
make && make tests

See the Build-time Customisation section below for configure options. If you plan on installing OpenSSH to your system, then you will usually want to specify destination paths.

Building from git

If building from git, you'll need autoconf installed to build the configure script. The following commands will check out and build portable OpenSSH from git:

git clone https://github.com/openssh/openssh-portable # or https://anongit.mindrot.org/openssh.git
cd openssh-portable
autoreconf
./configure
make && make tests

Build-time Customisation

There are many build-time customisation options available. All Autoconf destination path flags (e.g. --prefix) are supported (and are usually required if you want to install OpenSSH).

For a full list of available flags, run configure --help but a few of the more frequently-used ones are described below. Some of these flags will require additional libraries and/or headers be installed.

FlagMeaning
--with-pamEnable PAM support. OpenPAM, Linux PAM and Solaris PAM are supported.
--with-libeditEnable libedit support for sftp.
--with-kerberos5Enable Kerberos/GSSAPI support. Both Heimdal and MIT Kerberos implementations are supported.
--with-selinuxEnable SELinux support.
--with-security-key-builtinInclude built-in support for U2F/FIDO2 security keys. This requires libfido2 be installed.

Development

Portable OpenSSH development is discussed on the openssh-unix-dev mailing list (archive mirror). Bugs and feature requests are tracked on our Bugzilla.

Reporting bugs

Non-security bugs may be reported to the developers via Bugzilla or via the mailing list above. Security bugs should be reported to openssh@openssh.com.