File tree 2 files changed +33
-0
lines changed
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 45
45
AC_MSG_RESULT ( $has_valgrind )
46
46
] )
47
47
48
+ AC_DEFUN ( [ SECP_MSAN_CHECK] , [
49
+ AC_MSG_CHECKING ( whether MemorySanitizer is enabled )
50
+ AC_COMPILE_IFELSE ( [ AC_LANG_SOURCE ( [ [
51
+ #if defined(__has_feature)
52
+ # if __has_feature(memory_sanitizer)
53
+ # error "MemorySanitizer is enabled."
54
+ # endif
55
+ #endif
56
+ ] ] ) ] , [ msan_enabled=no] , [ msan_enabled=yes] )
57
+ AC_MSG_RESULT ( [ $msan_enabled] )
58
+ ] )
59
+
48
60
dnl SECP_TRY_APPEND_CFLAGS(flags, VAR)
49
61
dnl Append flags to VAR if CC accepts them.
50
62
AC_DEFUN ( [ SECP_TRY_APPEND_CFLAGS] , [
Original file line number Diff line number Diff line change @@ -247,6 +247,20 @@ if test x"$enable_ctime_tests" = x"auto"; then
247
247
enable_ctime_tests=$enable_valgrind
248
248
fi
249
249
250
+ print_msan_notice=no
251
+ if test x"$enable_ctime_tests" = x"yes" && test x"$GCC" = x"yes"; then
252
+ SECP_MSAN_CHECK
253
+ # MSan on Clang >=16 reports unitialized memory in function parameters and return values, even if
254
+ # the uninitalized variable is never actually "used". This is called "eager" checking, and it's
255
+ # sounds like good idea for normal use of MSan. However, it yields many false positives in the
256
+ # ctime_tests because many return values depend on secret (i.e., "uninitialized") values, and
257
+ # we're only interested in detecting branches (which count as "uses") on secret data.
258
+ if test x"$msan_enabled" = x"yes"; then
259
+ SECP_TRY_APPEND_CFLAGS([ -fno-sanitize-memory-param-retval] , SECP_CFLAGS)
260
+ fi
261
+ print_msan_notice=yes
262
+ fi
263
+
250
264
if test x"$enable_coverage" = x"yes"; then
251
265
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DCOVERAGE=1"
252
266
SECP_CFLAGS="-O0 --coverage $SECP_CFLAGS"
@@ -492,3 +506,10 @@ echo " CPPFLAGS = $CPPFLAGS"
492
506
echo " SECP_CFLAGS = $SECP_CFLAGS"
493
507
echo " CFLAGS = $CFLAGS"
494
508
echo " LDFLAGS = $LDFLAGS"
509
+
510
+ if test x"$print_msan_notice" = x"yes"; then
511
+ echo
512
+ echo "Note:"
513
+ echo " MemorySanitizer detected, tried to add -fno-sanitize-memory-param-retval to SECP_CFLAGS"
514
+ echo " to avoid false positives in ctime_tests. Pass --disable-ctime-tests to avoid this."
515
+ fi
You can’t perform that action at this time.
0 commit comments