git: 3e554a0ebf0a - stable/13 - atomic: Fix the atomic_load_ptr() *SAN interceptor
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 16 Feb 2023 22:39:32 UTC
The branch stable/13 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=3e554a0ebf0af4dcb95c5e3ffb7e32001b458dbb
commit 3e554a0ebf0af4dcb95c5e3ffb7e32001b458dbb
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-02-09 14:54:52 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-02-16 21:55:27 +0000
atomic: Fix the atomic_load_ptr() *SAN interceptor
The interceptor didn't handle a pointer of type "foo * const *" and in
that case we'd get compiler errors 1) an invalid cast to volatile
uintptr_t, and 2) an assignment to a variable of type "foo * const"
(__retptr).
Reported by: mjg
MFC after: 1 week
(cherry picked from commit 08b0c98006b6b9f3722df0ce462f6a4aa8ee06f2)
---
sys/sys/atomic_san.h | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/sys/sys/atomic_san.h b/sys/sys/atomic_san.h
index beeea82a666b..3a72cb4b4980 100644
--- a/sys/sys/atomic_san.h
+++ b/sys/sys/atomic_san.h
@@ -267,17 +267,11 @@ ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX);
#define atomic_fcmpset_acq_ptr ATOMIC_SAN(fcmpset_acq_ptr)
#define atomic_fcmpset_rel_ptr ATOMIC_SAN(fcmpset_rel_ptr)
#define atomic_fetchadd_ptr ATOMIC_SAN(fetchadd_ptr)
-#define atomic_load_ptr(x) ({ \
- __typeof(*x) __retptr; \
- __retptr = (void *)ATOMIC_SAN(load_ptr)((volatile uintptr_t *)(x)); \
- __retptr; \
-})
+#define atomic_load_ptr(x) \
+ ((void *)ATOMIC_SAN(load_ptr)(__DECONST(volatile uintptr_t *, (x))))
#define atomic_load_acq_ptr ATOMIC_SAN(load_acq_ptr)
-#define atomic_load_consume_ptr(x) ({ \
- __typeof(*x) __retptr; \
- __retptr = (void *)atomic_load_acq_ptr((volatile uintptr_t *)(x));\
- __retptr; \
-})
+#define atomic_load_consume_ptr(x) \
+ ((void *)atomic_load_acq_ptr((volatile uintptr_t *)(x)))
#define atomic_readandclear_ptr ATOMIC_SAN(readandclear_ptr)
#define atomic_set_ptr ATOMIC_SAN(set_ptr)
#define atomic_set_acq_ptr ATOMIC_SAN(set_acq_ptr)