Commit b16d8ecf authored by Will Deacon's avatar Will Deacon

compiler.h: Enforce that READ_ONCE_NOCHECK() access size is sizeof(long)

READ_ONCE_NOCHECK() unconditionally performs a sizeof(long)-sized access,
so enforce that the size of the pointed-to object that we are loading
from is the same size as 'long'.
Reported-by: default avatarMarco Elver <elver@google.com>
Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent 8d4beed7
......@@ -254,9 +254,12 @@ unsigned long __read_once_word_nocheck(const void *addr)
*/
#define READ_ONCE_NOCHECK(x) \
({ \
unsigned long __x = __read_once_word_nocheck(&(x)); \
unsigned long __x; \
compiletime_assert(sizeof(x) == sizeof(__x), \
"Unsupported access size for READ_ONCE_NOCHECK()."); \
__x = __read_once_word_nocheck(&(x)); \
smp_read_barrier_depends(); \
__x; \
(typeof(x))__x; \
})
static __no_kasan_or_inline
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment