Closed Bug 1307590 Opened 4 years ago Closed 4 years ago

UBSan: multiple warnings about misaligned int pointers

Categories

(NSS :: Libraries, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ttaubert, Assigned: ttaubert)

References

Details

Attachments

(1 file)

Attached file ubsan.txt
Running ssl_gtests with UBSan, we get a ton of warnings like:

load of misaligned address 0x60700000cfa1 for type 'uint32_t' (aka 'unsigned int'), which requires 4 byte alignment

Those are all coming from optimized ChaCha20, SHA-1, MD5, 3DES, and Curve25519 implementations, and are all found in code meant for architectures that handle misaligned pointers just fine.

We should use clang attributes to make UBSan happy.
Blocks: 1306947
https://hg.mozilla.org/projects/nss/rev/80edbfda8848
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 3.28
Not happy here: https://bot.nss-crypto.org:8011/builders/1-osx109-x64-DBG/builds/303/steps/shell/logs/stdio

gcc -arch x86_64 -o Darwin13.3.0_64_DBG.OBJ/Darwin_SINGLE_SHLIB/sha_fast.o -c -g -fPIC  -fno-common -pipe -DDARWIN -DHAVE_STRERROR -DHAVE_BSD_FLOCK  -Wall -Qunused-arguments -Wno-parentheses-equality -Werror -DXP_UNIX -DSHLIB_SUFFIX=\"dylib\" -DSHLIB_PREFIX=\"lib\" -DSHLIB_VERSION=\"3\" -DSOFTOKEN_SHLIB_VERSION=\"3\" -DRIJNDAEL_INCLUDE_TABLES -DDEBUG -UNDEBUG -DDEBUG_mozilla -DNSS_NO_INIT_SUPPORT -DUSE_UTIL_DIRECTLY -DNO_NSPR_10_SUPPORT -DSSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES -DNSS_USE_64 -DNSS_X86_OR_X64 -DNSS_X64 -DHAVE_INT128_SUPPORT -DMP_API_COMPATIBLE -I../../../dist/Darwin13.3.0_64_DBG.OBJ/include -I../../../dist/public/nss -I../../../dist/private/nss -Impi -Iecl  sha_fast.c
sha_fast.c:243:13: error: unknown attribute 'no_sanitize' ignored [-Werror,-Wattributes]
static void NO_SANITIZE_ALIGNMENT
            ^
./blapii.h:48:46: note: expanded from macro 'NO_SANITIZE_ALIGNMENT'
#define NO_SANITIZE_ALIGNMENT __attribute__((no_sanitize("alignment")))
                                             ^
1 error generated.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
It looks like this attribute isn't supported in older versions of clang.
This should help with clang < 3.7:

https://hg.mozilla.org/projects/nss/rev/c282555675df
Status: REOPENED → RESOLVED
Closed: 4 years ago4 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.