]> granicus.if.org Git - curl/commit
vtls: fix ssl session cache race condition
authorIvan Avdeev <me@w23.ru>
Wed, 1 Jun 2016 07:30:03 +0000 (09:30 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 1 Jun 2016 07:40:55 +0000 (09:40 +0200)
commit31c521b0470e57125ffcd0f1b0c6edf3b9af96c1
tree66cc86d09114eb504564e6b1400d89a0ca7bea85
parent6cabd78531f80d5c6cd942ed1aa97eaa5ec080df
vtls: fix ssl session cache race condition

Sessionid cache management is inseparable from managing individual
session lifetimes. E.g. for reference-counted sessions (like those in
SChannel and OpenSSL engines) every session addition and removal
should be accompanied with refcount increment and decrement
respectively. Failing to do so synchronously leads to a race condition
that causes symptoms like use-after-free and memory corruption.
This commit:
 - makes existing session cache locking explicit, thus allowing
   individual engines to manage lock's scope.
 - fixes OpenSSL and SChannel engines by putting refcount management
   inside this lock's scope in relevant places.
 - adds these explicit locking calls to other engines that use
   sessionid cache to accommodate for this change. Note, however,
   that it is unknown whether any of these engines could also have
   this race.

Bug: https://github.com/curl/curl/issues/815
Fixes #815
Closes #847
lib/urldata.h
lib/vtls/axtls.c
lib/vtls/cyassl.c
lib/vtls/darwinssl.c
lib/vtls/gtls.c
lib/vtls/mbedtls.c
lib/vtls/openssl.c
lib/vtls/polarssl.c
lib/vtls/schannel.c
lib/vtls/vtls.c
lib/vtls/vtls.h