openssh portable and libressl portable cause recursion between arc4random and RAND_bytes

Hanno Böck hanno at hboeck.de
Sat Jul 12 17:54:04 EST 2014


Hi,

Yesterday I tried to replace the system openssl in a gentoo system with
libressl.

With openssh an interesting issue popped up:
* RAND_bytes in libressl calls arc4random
* arc4random is a compat function both in openssh and libressl
* arc4random from openssh uses RAND_bytes

So what's happening is a recursion. arc4random wants to use RAND_bytes
and RAND_bytes wants to use arc4random. The result is a segfault.
OpenSSH is the latest 6.6.1.

A quick and working solution was to replace the openssh-arc4random with
the one shipped by libressl. One small change is needed: the
libressl-arc4random.c doesn't have the arc4random_stir()-function,
I copied that back from the openssh-arc4random.c.

Works so far, see attached patch.

An alternative would be to check for the availability of arc4random in
libcrypto and use that if available.

cu,
-- 
Hanno Böck
http://hboeck.de/

mail/jabber: hanno at hboeck.de
GPG: BBB51E42
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openssh-arc4random.diff.gz
Type: application/gzip
Size: 3055 bytes
Desc: not available
URL: <http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20140712/38ca69a7/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20140712/38ca69a7/attachment-0001.bin>


More information about the openssh-unix-dev mailing list