On 17/06/16 20:56, Matt Caswell via RT wrote: > > > On 17/06/16 19:43, Mick Saxton via RT wrote: >> Perhaps we should consider if there are any negative consequences to my >> solution? >> It does work. >> >> I am trying really hard to get contention but I am only seeing this problem >> in about 1 out of 100,000 successful TLSv1.2 connections >> On a heavily congested network. >> I require three machines to just to run the test that causes the failure. >> >> All we are trying to do is get a random number – surely getting a slightly >> less random number is better than crashing? >> It could be that the problematic instances were going to disconnect anyway >> due to TCP/IP problems. >> > > I think we need to try instrumenting the code to see if we can get some > more information out. I will try and pull something together - but it > might be Monday before I get the opportunity.
I got to it quicker than I thought. Please see attached patch. Can you apply it to the latest git 1.0.2 version and re-run your test (capture stderr output). I'd like to see what we get. Also is this 32-bit or 64-bit Windows? Are you able to share your locking callback implementation? Thanks Matt -- Ticket here: http://rt.openssl.org/Ticket/Display.html?id=4545 Please log in as guest with password guest if prompted
>From 71bec261502b5ad7ad3bb8ad39b069c49d42da5f Mon Sep 17 00:00:00 2001 From: Matt Caswell <m...@openssl.org> Date: Fri, 17 Jun 2016 23:57:13 +0100 Subject: [PATCH] Add some instrumentation to md_rand.c --- crypto/rand/md_rand.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crypto/rand/md_rand.c b/crypto/rand/md_rand.c index bd76e23..7c2931e 100644 --- a/crypto/rand/md_rand.c +++ b/crypto/rand/md_rand.c @@ -270,6 +270,19 @@ static void ssleay_rand_add(const void *buf, int num, double add) MD_Update(&m, local_md, MD_DIGEST_LENGTH); k = (st_idx + j) - STATE_SIZE; if (k > 0) { + if (j - k < 0) { + CRYPTO_THREADID thisthreadid; + CRYPTO_THREADID_current(&thisthreadid); + fprintf(stderr, "MD_RAND ERROR: ssleay_rand_add: k == %d, " + "j == %d, st_idx == %d, state_num == %ld, do_not_lock %d, " + "crypto_lock_rand == %d, locking_threadid == %lu, " + "thisthreadid == %lu\n", + k, j, st_idx, state_num, do_not_lock, crypto_lock_rand, + CRYPTO_THREADID_hash(&locking_threadid), + CRYPTO_THREADID_hash(&thisthreadid)); + fflush(stderr); + abort(); + } MD_Update(&m, &(state[st_idx]), j - k); MD_Update(&m, &(state[0]), k); } else @@ -492,6 +505,19 @@ int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo, int lock) k = (st_idx + MD_DIGEST_LENGTH / 2) - st_num; if (k > 0) { + if (MD_DIGEST_LENGTH / 2 - k < 0) { + CRYPTO_THREADID thisthreadid; + CRYPTO_THREADID_current(&thisthreadid); + fprintf(stderr, "MD_RAND ERROR: ssleay_rand_bytes: k == %d, " + "st_idx == %ld, st_num == %ld, lock %d, " + "crypto_lock_rand == %d, locking_threadid == %lu, " + "thisthreadid == %lu\n", + k, st_idx, st_num, lock, crypto_lock_rand, + CRYPTO_THREADID_hash(&locking_threadid), + CRYPTO_THREADID_hash(&thisthreadid)); + fflush(stderr); + abort(); + } MD_Update(&m, &(state[st_idx]), MD_DIGEST_LENGTH / 2 - k); MD_Update(&m, &(state[0]), k); } else -- 2.7.4
-- openssl-dev mailing list To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev