diff --git a/crypto/fipsmodule/rand/snapsafe_detect_test.cc b/crypto/fipsmodule/rand/snapsafe_detect_test.cc index d162aa12a2..666b8e9539 100644 --- a/crypto/fipsmodule/rand/snapsafe_detect_test.cc +++ b/crypto/fipsmodule/rand/snapsafe_detect_test.cc @@ -23,7 +23,7 @@ static int init_sgn_file(void** addr) { *addr = nullptr; // This file should've been created during test initialization - const int fd_sgn = open(CRYPTO_get_sysgenid_path(), O_RDWR | O_APPEND); + const int fd_sgn = open(CRYPTO_get_sysgenid_path(), O_RDWR); if (fd_sgn == -1) { return 0; } @@ -33,12 +33,9 @@ static int init_sgn_file(void** addr) { return 0; } - if (0 != fsync(fd_sgn)) { - return 0; - } - void* my_addr = mmap(nullptr, sizeof(uint32_t), PROT_WRITE, MAP_SHARED, fd_sgn, 0); if (my_addr == MAP_FAILED) { + close(fd_sgn); return 0; } diff --git a/crypto/fipsmodule/rand/urandom_test.cc b/crypto/fipsmodule/rand/urandom_test.cc index f6e7fa2e36..91a0cfc487 100644 --- a/crypto/fipsmodule/rand/urandom_test.cc +++ b/crypto/fipsmodule/rand/urandom_test.cc @@ -23,7 +23,8 @@ #include "snapsafe_detect.h" #if defined(OPENSSL_X86_64) && !defined(BORINGSSL_SHARED_LIBRARY) && \ - !defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) && defined(USE_NR_getrandom) + !defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) && \ + defined(USE_NR_getrandom) && !defined(AWSLC_SNAPSAFE_TESTING) #include @@ -611,13 +612,6 @@ int main(int argc, char **argv) { if (getenv("BORINGSSL_IGNORE_MADV_WIPEONFORK")) { CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing(); } -#if defined(OPENSSL_LINUX) && defined(AWSLC_SNAPSAFE_TESTING) - // When snapsafe testing is enabled, the sysgenid file must be created prior - // to running the test. - if (1 != HAZMAT_init_sysgenid_file()) { - abort(); - } -#endif return RUN_ALL_TESTS(); } @@ -630,4 +624,4 @@ int main(int argc, char **argv) { } #endif // X86_64 && !SHARED_LIBRARY && !UNSAFE_DETERMINISTIC_MODE && - // USE_NR_getrandom + // USE_NR_getrandom && !AWSLC_SNAPSAFE_TESTING