Skip to content

Commit

Permalink
Don't suppress UBSan unless compiling with UBSan (cossacklabs#556)
Browse files Browse the repository at this point in the history
Recently added SOTER_ED25519_NO_UBSAN macro is expanded into UBSan
tweaks even when we do not compile with Undefined Behavior sanitizer
enabled. This can produce ugly warnings on systems that do not support
all of the sanitizer flags.

Let's just expand this macro into a no-op if we are not compiling with
sanitizers. That's easier that deducing exactly which sanitizer flags
are supported to avoid compiler warnings.
  • Loading branch information
ilammy authored Nov 11, 2019
1 parent 4ebf103 commit 61365d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ CFLAGS += -fvisibility=hidden
#

ifdef WITH_ASAN
CFLAGS += -DWITH_ASAN
ifeq (yes,$(call supported,-fsanitize=address))
SANITIZERS += -fsanitize=address
else
Expand All @@ -323,6 +324,7 @@ endif
endif

ifdef WITH_MSAN
CFLAGS += -DWITH_MSAN
ifeq (yes,$(call supported,-fsanitize=memory))
SANITIZERS += -fsanitize=memory -fsanitize-memory-track-origins=2
else
Expand All @@ -331,6 +333,7 @@ endif
endif

ifdef WITH_TSAN
CFLAGS += -DWITH_TSAN
ifeq (yes,$(call supported,-fsanitize=thread))
SANITIZERS += -fsanitize=thread
else
Expand All @@ -339,6 +342,7 @@ endif
endif

ifdef WITH_UBSAN
CFLAGS += -DWITH_UBSAN
ifeq (yes,$(call supported,-fsanitize=undefined))
SANITIZERS += -fsanitize=undefined
else
Expand Down
4 changes: 2 additions & 2 deletions src/soter/ed25519/fe.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ typedef uint64_t crypto_uint64;

typedef crypto_int32 fe[10];

#if defined(__clang__)
#if defined(WITH_UBSAN) && defined(__clang__)
#define SOTER_ED25519_NO_UBSAN __attribute__((no_sanitize( \
"shift", \
"unsigned-integer-overflow", \
"implicit-integer-sign-change", \
"implicit-unsigned-integer-truncation", \
"implicit-signed-integer-truncation")))
#elif defined(__GNUC__)
#elif defined(WITH_UBSAN) && defined(__GNUC__)
#define SOTER_ED25519_NO_UBSAN __attribute__((no_sanitize("undefined")))
#else
#define SOTER_ED25519_NO_UBSAN
Expand Down

0 comments on commit 61365d0

Please sign in to comment.