]> git.ipfire.org Git - thirdparty/openssl.git/commit
Fix premature reuse of qp's in rcu locks
authorNeil Horman <nhorman@openssl.org>
Fri, 10 Jan 2025 19:37:28 +0000 (14:37 -0500)
committerTomas Mraz <tomas@openssl.org>
Tue, 14 Jan 2025 10:44:13 +0000 (11:44 +0100)
commit31cbf5f73234391f042c8417cb26ada0151f202a
tree9f28eb7516ea4bac2d2c721fb2689df5d3520a61
parentf257c4c9a4d27c259ef544ec8efe8040e6a37f9d
Fix premature reuse of qp's in rcu locks

An intermittent failure was noted on our new ppc64le CI runner, in which
what appeared to be a corrupted or invalid value getting returned from a
shared pointer under rcu protection

Investigation showed that the problem was with our small number of qp's
in a lock, and slightly incorrect accounting of the number of qp's
available we were prematurely recycling qp's, which led in turn to
premature completion of synchronization states, resulting in readers
reading memory that may have already been freed.

Fix it by:
a) Ensuring that we account for the fact that the first qp in an rcu
lock is allocated at the time the lock is created

and

b) Ensuring that we have a minimum number of 3 qp's:
1 that is free for write side allocation
1 that is in use by the write side currently
1 "next" qp that the read side can update while the prior qp is being
retired

With this change, the rcu threadstest runs indefinately in my testing

Fixes #26356

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26384)

(cherry picked from commit 25f8e2c15b701514b7b2fe652634289b6fb8581f)
crypto/threads_pthread.c
crypto/threads_win.c