Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sha256: msan support #2998

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/ballet/sha256/fd_sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ fd_sha256_core_ref( uint * state,
# undef sigma1
# undef Ch
# undef Maj

fd_msan_unpoison( state, 32UL );
}

#define fd_sha256_core fd_sha256_core_ref
Expand All @@ -226,7 +226,10 @@ fd_sha256_core_shaext( uint * state, /* 64-byte aligned, 8 entries
uchar const * block, /* ideally 128-byte aligned (but not required), 128*block_cnt in size */
ulong block_cnt ); /* positive */

#define fd_sha256_core fd_sha256_core_shaext
inline void fd_sha256_core( uint * state, uchar const * block, ulong block_cnt ) {
fd_sha256_core_shaext( state, block, block_cnt );
fd_msan_unpoison( state, 32UL );
}

#else
#error "Unsupported FD_SHA256_CORE_IMPL"
Expand Down
12 changes: 6 additions & 6 deletions src/util/sanitize/fd_msan.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ void __msan_poison ( void const volatile * addr, ulong sz );
void __msan_unpoison ( void const volatile * addr, ulong sz );
void __msan_check_mem_is_initialized( void const volatile * addr, ulong sz );

static inline void * fd_msan_poison ( void * addr, ulong sz ) { __msan_poison ( addr, sz ); return addr; }
static inline void * fd_msan_unpoison( void * addr, ulong sz ) { __msan_unpoison( addr, sz ); return addr; }
static inline void fd_msan_check ( void const * addr, ulong sz ) { __msan_check_mem_is_initialized( addr, sz ); }
inline void * fd_msan_poison ( void * addr, ulong sz ) { __msan_poison ( addr, sz ); return addr; }
inline void * fd_msan_unpoison( void * addr, ulong sz ) { __msan_unpoison( addr, sz ); return addr; }
inline void fd_msan_check ( void const * addr, ulong sz ) { __msan_check_mem_is_initialized( addr, sz ); }

#else

static inline void * fd_msan_poison ( void * addr, ulong sz ) { (void)sz; return addr; }
static inline void * fd_msan_unpoison( void * addr, ulong sz ) { (void)sz; return addr; }
static inline void fd_msan_check ( void const * addr, ulong sz ) { (void)addr; (void)sz; }
inline void * fd_msan_poison ( void * addr, ulong sz ) { (void)sz; return addr; }
inline void * fd_msan_unpoison( void * addr, ulong sz ) { (void)sz; return addr; }
inline void fd_msan_check ( void const * addr, ulong sz ) { (void)addr; (void)sz; }

#endif

Expand Down
Loading