atomic: Intercept atomic_(load|store)_bool for kernel sanitizers

Fixes:		2bed73739a ("atomic: Add plain atomic_load/store_bool()")
This commit is contained in:
Mark Johnston 2022-10-29 11:02:02 -04:00
parent 234c1463a7
commit 1f6b6cf177
4 changed files with 23 additions and 2 deletions

View File

@ -843,6 +843,7 @@ ASAN_ATOMIC_FUNC_FCMPSET(int, u_int);
ASAN_ATOMIC_FUNC_FCMPSET(long, u_long);
ASAN_ATOMIC_FUNC_FCMPSET(ptr, uintptr_t);
_ASAN_ATOMIC_FUNC_LOAD(bool, bool);
ASAN_ATOMIC_FUNC_LOAD(8, uint8_t);
ASAN_ATOMIC_FUNC_LOAD(16, uint16_t);
ASAN_ATOMIC_FUNC_LOAD(32, uint32_t);
@ -853,6 +854,7 @@ ASAN_ATOMIC_FUNC_LOAD(int, u_int);
ASAN_ATOMIC_FUNC_LOAD(long, u_long);
ASAN_ATOMIC_FUNC_LOAD(ptr, uintptr_t);
_ASAN_ATOMIC_FUNC_STORE(bool, bool);
ASAN_ATOMIC_FUNC_STORE(8, uint8_t);
ASAN_ATOMIC_FUNC_STORE(16, uint16_t);
ASAN_ATOMIC_FUNC_STORE(32, uint32_t);

View File

@ -520,6 +520,9 @@ kcsan_copyout(const void *kaddr, void *uaddr, size_t len)
return (atomic_testandset_##name(ptr, val)); \
}
_CSAN_ATOMIC_FUNC_LOAD(bool, bool)
_CSAN_ATOMIC_FUNC_STORE(bool, bool)
CSAN_ATOMIC_FUNC_ADD(8, uint8_t)
CSAN_ATOMIC_FUNC_CLEAR(8, uint8_t)
CSAN_ATOMIC_FUNC_CMPSET(8, uint8_t)

View File

@ -1375,6 +1375,7 @@ MSAN_ATOMIC_FUNC_FCMPSET(int, u_int);
MSAN_ATOMIC_FUNC_FCMPSET(long, u_long);
MSAN_ATOMIC_FUNC_FCMPSET(ptr, uintptr_t);
_MSAN_ATOMIC_FUNC_LOAD(bool, bool);
MSAN_ATOMIC_FUNC_LOAD(8, uint8_t);
MSAN_ATOMIC_FUNC_LOAD(16, uint16_t);
MSAN_ATOMIC_FUNC_LOAD(32, uint32_t);
@ -1385,6 +1386,7 @@ MSAN_ATOMIC_FUNC_LOAD(int, u_int);
MSAN_ATOMIC_FUNC_LOAD(long, u_long);
MSAN_ATOMIC_FUNC_LOAD(ptr, uintptr_t);
_MSAN_ATOMIC_FUNC_STORE(bool, bool);
MSAN_ATOMIC_FUNC_STORE(8, uint8_t);
MSAN_ATOMIC_FUNC_STORE(16, uint16_t);
MSAN_ATOMIC_FUNC_STORE(32, uint32_t);

View File

@ -65,11 +65,15 @@
type sp##_atomic_readandclear_##name(volatile type *)
#define ATOMIC_SAN_LOAD(sp, name, type) \
type sp##_atomic_load_##name(volatile type *); \
type sp##_atomic_load_##name(volatile type *)
#define ATOMIC_SAN_LOAD_ACQ(sp, name, type) \
type sp##_atomic_load_acq_##name(volatile type *)
#define ATOMIC_SAN_STORE(sp, name, type) \
void sp##_atomic_store_##name(volatile type *, type); \
void sp##_atomic_store_##name(volatile type *, type)
#define ATOMIC_SAN_STORE_REL(sp, name, type) \
void sp##_atomic_store_rel_##name(volatile type *, type)
#define ATOMIC_SAN_TEST(sp, op, name, type) \
@ -86,6 +90,10 @@
#define ATOMIC_SAN_THREAD_FENCE(sp) \
_ATOMIC_SAN_THREAD_FENCE(sp)
#define ATOMIC_SAN_LOAD_STORE(sp, name, type) \
ATOMIC_SAN_LOAD(sp, name, type); \
ATOMIC_SAN_STORE(sp, name, type)
#define _ATOMIC_SAN_FUNCS(sp, name, type) \
ATOMIC_SAN_FUNC_1(sp, add, name, type); \
ATOMIC_SAN_FUNC_1(sp, clear, name, type); \
@ -93,10 +101,12 @@
ATOMIC_SAN_FCMPSET(sp, name, type); \
ATOMIC_SAN_READ(sp, fetchadd, name, type); \
ATOMIC_SAN_LOAD(sp, name, type); \
ATOMIC_SAN_LOAD_ACQ(sp, name, type); \
ATOMIC_SAN_READANDCLEAR(sp, name, type); \
ATOMIC_SAN_FUNC_1(sp, set, name, type); \
ATOMIC_SAN_FUNC_1(sp, subtract, name, type); \
ATOMIC_SAN_STORE(sp, name, type); \
ATOMIC_SAN_STORE_REL(sp, name, type); \
ATOMIC_SAN_READ(sp, swap, name, type); \
ATOMIC_SAN_TEST(sp, testandclear, name, type); \
ATOMIC_SAN_TEST(sp, testandset, name, type)
@ -113,6 +123,7 @@ ATOMIC_SAN_FUNCS(8, uint8_t);
ATOMIC_SAN_FUNCS(16, uint16_t);
ATOMIC_SAN_FUNCS(32, uint32_t);
ATOMIC_SAN_FUNCS(64, uint64_t);
ATOMIC_SAN_LOAD_STORE(SAN_INTERCEPTOR_PREFIX, bool, bool);
ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX);
#ifndef SAN_RUNTIME
@ -125,6 +136,9 @@ ATOMIC_SAN_THREAD_FENCE(SAN_INTERCEPTOR_PREFIX);
#define ATOMIC_SAN(func) \
__CONCAT(SAN_INTERCEPTOR_PREFIX, __CONCAT(_atomic_, func))
#define atomic_load_bool ATOMIC_SAN(load_bool)
#define atomic_store_bool ATOMIC_SAN(store_bool)
#define atomic_add_char ATOMIC_SAN(add_char)
#define atomic_add_acq_char ATOMIC_SAN(add_acq_char)
#define atomic_add_rel_char ATOMIC_SAN(add_rel_char)