diff options
author | Andy Polyakov <appro@openssl.org> | 2018-07-29 14:12:53 +0200 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2018-08-07 09:08:23 +0200 |
commit | 9ef9088c1585e13b9727796f15f77da64dbbe623 (patch) | |
tree | d19a8b9c42b0226d785889655af053c24ee86af6 /ssl/statem | |
parent | cab76c0f6482df5140efa2ca93c9e2d972fcd9b0 (diff) |
ssl/*: switch to switch to Thread-Sanitizer-friendly primitives.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6786)
Diffstat (limited to 'ssl/statem')
-rw-r--r-- | ssl/statem/extensions.c | 8 | ||||
-rw-r--r-- | ssl/statem/statem_clnt.c | 4 | ||||
-rw-r--r-- | ssl/statem/statem_lib.c | 23 |
3 files changed, 11 insertions, 24 deletions
diff --git a/ssl/statem/extensions.c b/ssl/statem/extensions.c index 85945acc0d..12c712e8e6 100644 --- a/ssl/statem/extensions.c +++ b/ssl/statem/extensions.c @@ -912,7 +912,7 @@ static int init_server_name(SSL *s, unsigned int context) static int final_server_name(SSL *s, unsigned int context, int sent) { - int ret = SSL_TLSEXT_ERR_NOACK, discard; + int ret = SSL_TLSEXT_ERR_NOACK; int altmp = SSL_AD_UNRECOGNIZED_NAME; int was_ticket = (SSL_get_options(s) & SSL_OP_NO_TICKET) == 0; @@ -960,10 +960,8 @@ static int final_server_name(SSL *s, unsigned int context, int sent) * exceed sess_accept (zero) for the new context. */ if (SSL_IS_FIRST_HANDSHAKE(s) && s->ctx != s->session_ctx) { - CRYPTO_atomic_add(&s->ctx->stats.sess_accept, 1, &discard, - s->ctx->lock); - CRYPTO_atomic_add(&s->session_ctx->stats.sess_accept, -1, &discard, - s->session_ctx->lock); + tsan_counter(&s->ctx->stats.sess_accept); + tsan_counter(&s->session_ctx->stats.sess_accept); } /* diff --git a/ssl/statem/statem_clnt.c b/ssl/statem/statem_clnt.c index e846f772a6..3dc29cc757 100644 --- a/ssl/statem/statem_clnt.c +++ b/ssl/statem/statem_clnt.c @@ -1409,7 +1409,6 @@ MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt) unsigned int compression; unsigned int sversion; unsigned int context; - int discard; RAW_EXTENSION *extensions = NULL; #ifndef OPENSSL_NO_COMP SSL_COMP *comp; @@ -1616,8 +1615,7 @@ MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt) || (SSL_IS_TLS13(s) && s->session->ext.tick_identity != TLSEXT_PSK_BAD_IDENTITY)) { - CRYPTO_atomic_add(&s->session_ctx->stats.sess_miss, 1, &discard, - s->session_ctx->lock); + tsan_counter(&s->session_ctx->stats.sess_miss); if (!ssl_get_new_session(s, 0)) { /* SSLfatal() already called */ goto err; diff --git a/ssl/statem/statem_lib.c b/ssl/statem/statem_lib.c index ebb21deb8b..caed61aaac 100644 --- a/ssl/statem/statem_lib.c +++ b/ssl/statem/statem_lib.c @@ -132,23 +132,18 @@ int tls_setup_handshake(SSL *s) } if (SSL_IS_FIRST_HANDSHAKE(s)) { /* N.B. s->session_ctx == s->ctx here */ - CRYPTO_atomic_add(&s->session_ctx->stats.sess_accept, 1, &i, - s->session_ctx->lock); + tsan_counter(&s->session_ctx->stats.sess_accept); } else { /* N.B. s->ctx may not equal s->session_ctx */ - CRYPTO_atomic_add(&s->ctx->stats.sess_accept_renegotiate, 1, &i, - s->ctx->lock); + tsan_counter(&s->ctx->stats.sess_accept_renegotiate); s->s3->tmp.cert_request = 0; } } else { - int discard; if (SSL_IS_FIRST_HANDSHAKE(s)) - CRYPTO_atomic_add(&s->session_ctx->stats.sess_connect, 1, &discard, - s->session_ctx->lock); + tsan_counter(&s->session_ctx->stats.sess_connect); else - CRYPTO_atomic_add(&s->session_ctx->stats.sess_connect_renegotiate, - 1, &discard, s->session_ctx->lock); + tsan_counter(&s->session_ctx->stats.sess_connect_renegotiate); /* mark client_random uninitialized */ memset(s->s3->client_random, 0, sizeof(s->s3->client_random)); @@ -1009,7 +1004,6 @@ unsigned long ssl3_output_cert_chain(SSL *s, WPACKET *pkt, CERT_PKEY *cpk) */ WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst, int clearbufs, int stop) { - int discard; void (*cb) (const SSL *ssl, int type, int val) = NULL; if (clearbufs) { @@ -1055,8 +1049,7 @@ WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst, int clearbufs, int stop) ssl_update_cache(s, SSL_SESS_CACHE_SERVER); /* N.B. s->ctx may not equal s->session_ctx */ - CRYPTO_atomic_add(&s->ctx->stats.sess_accept_good, 1, &discard, - s->ctx->lock); + tsan_counter(&s->ctx->stats.sess_accept_good); s->handshake_func = ossl_statem_accept; if (SSL_IS_DTLS(s) && !s->hit) { @@ -1084,12 +1077,10 @@ WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst, int clearbufs, int stop) ssl_update_cache(s, SSL_SESS_CACHE_CLIENT); } if (s->hit) - CRYPTO_atomic_add(&s->session_ctx->stats.sess_hit, 1, &discard, - s->session_ctx->lock); + tsan_counter(&s->session_ctx->stats.sess_hit); s->handshake_func = ossl_statem_connect; - CRYPTO_atomic_add(&s->session_ctx->stats.sess_connect_good, 1, - &discard, s->session_ctx->lock); + tsan_counter(&s->session_ctx->stats.sess_connect_good); if (SSL_IS_DTLS(s) && s->hit) { /* |