]> git.ipfire.org Git - thirdparty/openssl.git/commit
crypto/threads_pthread.c: refactor all atomics fallbacks for type safety
authorRichard Levitte <levitte@openssl.org>
Fri, 12 Apr 2024 08:03:21 +0000 (10:03 +0200)
committerTomas Mraz <tomas@openssl.org>
Tue, 16 Apr 2024 07:18:45 +0000 (09:18 +0200)
commit8cecc55b85219c9e1f08012c4d2d0687d985625f
tree8f426816c7837150c9af2fa86f580743df711952
parent6d1963b2dfb878652546bfa107dde6962f2e55c8
crypto/threads_pthread.c: refactor all atomics fallbacks for type safety

The atomics fallbacks were using 'void *' as a generic transport for all
possible scalar and pointer types, with the hypothesis that a pointer is
as large as the largest possible scalar type that we would use.

Then enters the use of uint64_t, which is larger than a pointer on any
32-bit system (or any system that has 32-bit pointer configurations).

We could of course choose a larger type as a generic transport.  However,
that only pushes the problem forward in time...  and it's still a hack.
It's therefore safer to reimplement the fallbacks per type that atomics
are used for, and deal with missing per type fallbacks when the need
arrises in the future.

For test build purposes, the macro USE_ATOMIC_FALLBACKS is introduced.
If OpenSSL is configured with '-DUSE_ATOMIC_FALLBACKS', the fallbacks
will be used, unconditionally.

Fixes #24096

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24123)

(cherry picked from commit a02077d4d7aeb0c99cc88cdfc7c131e48f98c4de)
crypto/threads_pthread.c