From a70d583ea8924384e519b38efd2b51fb20e49f48 Mon Sep 17 00:00:00 2001 From: Jou Ho Date: Fri, 11 Oct 2024 17:07:09 +0000 Subject: [PATCH 1/5] repro issue --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b14702427d1..a8b83e11f2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,8 +204,8 @@ if(NO_STACK_PROTECTOR) endif() if(S2N_FUZZ_TEST) - target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=fuzzer-no-link,leak) - target_link_libraries(${PROJECT_NAME} PUBLIC -fsanitize=fuzzer-no-link,leak) + target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=fuzzer-no-link,leak,address,undefined) + target_link_libraries(${PROJECT_NAME} PUBLIC -fsanitize=fuzzer-no-link,leak,address,undefined) endif() if(TSAN) From 5960e4780e330699caf5ab58daafc14527d31ea0 Mon Sep 17 00:00:00 2001 From: Jou Ho Date: Fri, 11 Oct 2024 18:32:22 +0000 Subject: [PATCH 2/5] disable MAD_DONTDUMP --- utils/s2n_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/s2n_mem.c b/utils/s2n_mem.c index 7f8b2afa03e..b49a182c90d 100644 --- a/utils/s2n_mem.c +++ b/utils/s2n_mem.c @@ -104,7 +104,7 @@ static int s2n_mem_malloc_mlock_impl(void **ptr, uint32_t requested, uint32_t *a ** We disable MAD_DONTDUMP when fuzz-testing or using the address sanitizer because ** both need to be able to dump pages to function. It's how they map heap output. */ -#if defined(MADV_DONTDUMP) && !defined(S2N_ADDRESS_SANITIZER) && !defined(S2N_FUZZ_TESTING) +#if defined(MADV_DONTDUMP) && !defined(S2N_ADDRESS_SANITIZER) && !defined(S2N_FUZZ_TEST) if (madvise(*ptr, *allocated, MADV_DONTDUMP) != 0) { POSIX_GUARD(s2n_mem_free_no_mlock_impl(*ptr, *allocated)); POSIX_BAIL(S2N_ERR_MADVISE); From 1fad083bf56721ba66c39210ce9cdce36ba35dbd Mon Sep 17 00:00:00 2001 From: Jou Ho Date: Fri, 11 Oct 2024 19:49:06 +0000 Subject: [PATCH 3/5] add correct compile option to disable MAD_DONTDUMP --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a8b83e11f2a..bcac1bceec6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,6 +204,7 @@ if(NO_STACK_PROTECTOR) endif() if(S2N_FUZZ_TEST) + target_compile_definitions(${PROJECT_NAME} PUBLIC -DS2N_FUZZ_TEST=1) target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=fuzzer-no-link,leak,address,undefined) target_link_libraries(${PROJECT_NAME} PUBLIC -fsanitize=fuzzer-no-link,leak,address,undefined) endif() From c082ab3d371a47ff7f785ad6aefa76352a26099a Mon Sep 17 00:00:00 2001 From: Jou Ho Date: Fri, 11 Oct 2024 20:11:47 +0000 Subject: [PATCH 4/5] refactor namings --- CMakeLists.txt | 2 +- utils/s2n_mem.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bcac1bceec6..a6c4a07364e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,7 +204,7 @@ if(NO_STACK_PROTECTOR) endif() if(S2N_FUZZ_TEST) - target_compile_definitions(${PROJECT_NAME} PUBLIC -DS2N_FUZZ_TEST=1) + target_compile_definitions(${PROJECT_NAME} PUBLIC -DS2N_FUZZ_TESTING=1) target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=fuzzer-no-link,leak,address,undefined) target_link_libraries(${PROJECT_NAME} PUBLIC -fsanitize=fuzzer-no-link,leak,address,undefined) endif() diff --git a/utils/s2n_mem.c b/utils/s2n_mem.c index b49a182c90d..7f8b2afa03e 100644 --- a/utils/s2n_mem.c +++ b/utils/s2n_mem.c @@ -104,7 +104,7 @@ static int s2n_mem_malloc_mlock_impl(void **ptr, uint32_t requested, uint32_t *a ** We disable MAD_DONTDUMP when fuzz-testing or using the address sanitizer because ** both need to be able to dump pages to function. It's how they map heap output. */ -#if defined(MADV_DONTDUMP) && !defined(S2N_ADDRESS_SANITIZER) && !defined(S2N_FUZZ_TEST) +#if defined(MADV_DONTDUMP) && !defined(S2N_ADDRESS_SANITIZER) && !defined(S2N_FUZZ_TESTING) if (madvise(*ptr, *allocated, MADV_DONTDUMP) != 0) { POSIX_GUARD(s2n_mem_free_no_mlock_impl(*ptr, *allocated)); POSIX_BAIL(S2N_ERR_MADVISE); From a4cbc065c827f15f30b42c891c122ea9a6c43587 Mon Sep 17 00:00:00 2001 From: Jou Ho Date: Tue, 15 Oct 2024 16:51:41 +0000 Subject: [PATCH 5/5] remove -D flag for simplicity --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6c4a07364e..77e76acc1a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,7 +204,7 @@ if(NO_STACK_PROTECTOR) endif() if(S2N_FUZZ_TEST) - target_compile_definitions(${PROJECT_NAME} PUBLIC -DS2N_FUZZ_TESTING=1) + target_compile_definitions(${PROJECT_NAME} PUBLIC S2N_FUZZ_TESTING=1) target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=fuzzer-no-link,leak,address,undefined) target_link_libraries(${PROJECT_NAME} PUBLIC -fsanitize=fuzzer-no-link,leak,address,undefined) endif()