Skip to content

Commit

Permalink
random: workaround MSAN false positive
Browse files Browse the repository at this point in the history
In Ubuntu 24.04, glibc has arc4random_buf included, which triggers this
path for the fuzzer. Unfortunately, MSAN appears to not realise that the
iv buffer for aes256_cbc_fips() is in fact initialized by this function
call. We work around it by manually marking the memory contents as
initialized.
  • Loading branch information
LDVG committed Oct 7, 2024
1 parent 982215c commit c7a5823
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
#include <unistd.h>
#endif

#if defined(__has_feature)
# if __has_feature(memory_sanitizer)
# include <sanitizer/msan_interface.h>
# define WITH_MSAN 1
# endif
#endif

#include "fido.h"

#if defined(_WIN32)
Expand Down Expand Up @@ -45,6 +52,9 @@ int
fido_get_random(void *buf, size_t len)
{
arc4random_buf(buf, len);
#ifdef WITH_MSAN
__msan_unpoison(buf, len); /* XXX */
#endif
return (0);
}
#elif defined(HAVE_GETRANDOM)
Expand Down

0 comments on commit c7a5823

Please sign in to comment.