Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 566074 - dev-libs/openssl-1.0.2d Locking Error in ssleay_rand_bytes() - Possible Denial of Service Vulnerability
Summary: dev-libs/openssl-1.0.2d Locking Error in ssleay_rand_bytes() - Possible Denia...
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Security
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-17 18:03 UTC by Christian Ehrig
Modified: 2015-11-23 00:14 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Ehrig 2015-11-17 18:03:01 UTC
Debugging a multi-threaded C application using libssl for a lot of concurrent requests with Helgrind, I am experiencing the following Errors:

==13234== ---Thread-Announcement------------------------------------------
==13234== 
==13234== Thread #15 was created
==13234==    at 0x5DF501E: clone (clone.S:74)
==13234==    by 0x506031F: do_clone.constprop.3 (createthread.c:81)
==13234==    by 0x50618A2: create_thread (createthread.c:251)
==13234==    by 0x50618A2: pthread_create@@GLIBC_2.2.5 (pthread_create.c:608)
==13234==    by 0x4C2E29D: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==13234==    by 0x403869: encryptedConnections (main.c:229)
==13234==    by 0x4C2E436: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==13234==    by 0x5061181: start_thread (pthread_create.c:310)
==13234== 
==13234== ----------------------------------------------------------------
==13234== 
==13234==  Lock at 0x67CAD40 was first observed
==13234==    at 0x4C2F66A: pthread_mutex_init (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==13234==    by 0x4036E9: init_ssl_locks (main.c:191)
==13234==    by 0x4037DC: encryptedConnections (main.c:219)
==13234==    by 0x4C2E436: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==13234==    by 0x5061181: start_thread (pthread_create.c:310)
==13234==  Address 0x67cad40 is 720 bytes inside a block of size 1,640 alloc'd
==13234==    at 0x4C29420: malloc (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==13234==    by 0x5634351: CRYPTO_malloc (mem.c:342)
==13234==    by 0x4036AE: init_ssl_locks (main.c:187)
==13234==    by 0x4037DC: encryptedConnections (main.c:219)
==13234==    by 0x4C2E436: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==13234==    by 0x5061181: start_thread (pthread_create.c:310)
==13234==  Block was alloc'd by thread #5
==13234== 
==13234== Possible data race during write of size 4 at 0x58B47C0 by thread #15
==13234== Locks held: 1, at address 0x67CAD40
==13234==    at 0x55C9979: ssleay_rand_bytes (md_rand.c:392)
==13234==    by 0x55D11C7: aes_gcm_ctrl (e_aes.c:1201)
==13234==    by 0x55CDA33: EVP_CIPHER_CTX_ctrl (evp_enc.c:619)
==13234==    by 0x52AA055: tls1_change_cipher_state (t1_enc.c:559)
==13234==    by 0x5295CA3: ssl3_accept (s3_srvr.c:792)
==13234==    by 0x52A39DC: ssl23_accept (s23_srvr.c:209)
==13234==    by 0x403DC3: sock_bind_ssl (socket.c:138)
==13234==    by 0x4042B1: client_thread (client_thread.c:16)
==13234==    by 0x4C2E436: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==13234==    by 0x5061181: start_thread (pthread_create.c:310)
==13234== 
==13234== This conflicts with a previous write of size 4 by thread #12
==13234== Locks held: 1, at address 0x67CAD40
==13234==    at 0x55C9979: ssleay_rand_bytes (md_rand.c:392)
==13234==    by 0x52954B1: ssl3_send_newsession_ticket (s3_srvr.c:3411)
==13234==    by 0x5295EE0: ssl3_accept (s3_srvr.c:755)
==13234==    by 0x52A39DC: ssl23_accept (s23_srvr.c:209)
==13234==    by 0x403DC3: sock_bind_ssl (socket.c:138)
==13234==    by 0x4042B1: client_thread (client_thread.c:16)
==13234==    by 0x4C2E436: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==13234==    by 0x5061181: start_thread (pthread_create.c:310)
==13234==  Address 0x58b47c0 is 0 bytes inside data symbol "crypto_lock_rand"
==13234== 



id_function and locking-function are implemented as usual and seem to work. It seems that the issue is well known on Red Hat side: 
- http://tools.cisco.com/security/center/viewAlert.x?alertId=39390
- https://bugzilla.redhat.com/show_bug.cgi?id=1226209
- https://bugzilla.redhat.com/show_bug.cgi?id=1227574

After a lot of requests the application just crashes with error code 141.

Emerge Info:

Portage 2.2.20.1 (python 2.7.10-final-0, default/linux/amd64/13.0, gcc-4.8.4, glibc-2.20-r2, 4.0.5-gentoo x86_64)
=================================================================
System uname: Linux-4.0.5-gentoo-x86_64-Intel-R-_Core-TM-_M-5Y51_CPU_@_1.10GHz-with-gentoo-2.2
KiB Mem:     4048420 total,    595920 free
KiB Swap:    4194300 total,   4173088 free
sh bash 4.3_p39
ld GNU ld (Gentoo 2.25.1 p1.1) 2.25.1
app-shells/bash:          4.3_p39::gentoo
dev-java/java-config:     2.2.0::gentoo
dev-lang/perl:            5.20.2::gentoo
dev-lang/python:          2.7.10::gentoo, 3.4.3::gentoo
dev-util/cmake:           3.3.1-r1::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.17::gentoo
sys-apps/sandbox:         2.6-r1::gentoo
sys-devel/autoconf:       2.69::gentoo
sys-devel/automake:       1.14.1::gentoo, 1.15::gentoo
sys-devel/binutils:       2.25.1-r1::gentoo
sys-devel/gcc:            4.8.4::gentoo, 4.9.3::gentoo
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 3.18::gentoo (virtual/os-headers)
sys-libs/glibc:           2.20-r2::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=nocona -O2 -pipe -ggdb -fno-builtin-strlen -DPURIFY"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.6/ext-active/ /etc/php/cgi-php5.6/ext-active/ /etc/php/cli-php5.6/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=nocona -O2 -pipe -ggdb -fno-builtin-strlen -DPURIFY"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news nostrip parallel-fetch preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.utf8"
LC_ALL="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
USE="acl amd64 apache2 berkdb bindist bzip2 cli cracklib crypt cxx dri exif fortran gd gdbm iconv ipv6 mmx mmxext modules multilib mysql mysqli ncurses nls nptl openmp pam pcre pdo php readline seccomp session sockets sse sse2 ssl tcpd unicode xattr zip zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby20 ruby21" USERLAND="GNU" VIDEO_CARDS="fbdev glint intel mach64 mga nouveau nv r128 radeon savage sis tdfx trident vesa via vmware dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON


Reproducible: Always
Comment 1 SpanKY gentoo-dev 2015-11-23 00:14:03 UTC
the reports you refer to do not look related.  they specifically talk about how redhat is carrying a unique patch that caused the problem.

please post a small testcase that shows the problem.