summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2021-12-30 21:27:23 (GMT)
committerQi Wang <interwq@gmail.com>2022-01-04 19:03:51 (GMT)
commitd660683d3ddc2aaebf41a5662a6bc629be016e6d (patch)
treed2d7ee9398706cd668d13c5238e92f501c6ff2b0
parenteabe88916290fec452048eaa1abe1cd52a794339 (diff)
downloadjemalloc-d660683d3ddc2aaebf41a5662a6bc629be016e6d.zip
jemalloc-d660683d3ddc2aaebf41a5662a6bc629be016e6d.tar.gz
jemalloc-d660683d3ddc2aaebf41a5662a6bc629be016e6d.tar.bz2
Fix test config of lg_san_uaf_align.
The option may be configure-disabled, which resulted in the invalid options output from the tests.
-rw-r--r--test/include/test/san.h8
-rw-r--r--test/unit/tcache_max.c3
-rw-r--r--test/unit/tcache_max.sh2
-rw-r--r--test/unit/uaf.c6
-rw-r--r--test/unit/uaf.sh3
5 files changed, 17 insertions, 5 deletions
diff --git a/test/include/test/san.h b/test/include/test/san.h
index 691dc50..da07865 100644
--- a/test/include/test/san.h
+++ b/test/include/test/san.h
@@ -1,3 +1,11 @@
+#if defined(JEMALLOC_UAF_DETECTION) || defined(JEMALLOC_DEBUG)
+# define TEST_SAN_UAF_ALIGN_ENABLE "lg_san_uaf_align:12"
+# define TEST_SAN_UAF_ALIGN_DISABLE "lg_san_uaf_align:-1"
+#else
+# define TEST_SAN_UAF_ALIGN_ENABLE ""
+# define TEST_SAN_UAF_ALIGN_DISABLE ""
+#endif
+
static inline bool
extent_is_guarded(tsdn_t *tsdn, void *ptr) {
edata_t *edata = emap_edata_lookup(tsdn, &arena_emap_global, ptr);
diff --git a/test/unit/tcache_max.c b/test/unit/tcache_max.c
index 7b4217d..1f657c8 100644
--- a/test/unit/tcache_max.c
+++ b/test/unit/tcache_max.c
@@ -1,4 +1,7 @@
#include "test/jemalloc_test.h"
+#include "test/san.h"
+
+const char *malloc_conf = TEST_SAN_UAF_ALIGN_DISABLE;
enum {
alloc_option_start = 0,
diff --git a/test/unit/tcache_max.sh b/test/unit/tcache_max.sh
index 278c4ad..4480d73 100644
--- a/test/unit/tcache_max.sh
+++ b/test/unit/tcache_max.sh
@@ -1,3 +1,3 @@
#!/bin/sh
-export MALLOC_CONF="tcache_max:1024,lg_san_uaf_align:-1"
+export MALLOC_CONF="tcache_max:1024"
diff --git a/test/unit/uaf.c b/test/unit/uaf.c
index 880aee4..a8433c2 100644
--- a/test/unit/uaf.c
+++ b/test/unit/uaf.c
@@ -1,9 +1,13 @@
#include "test/jemalloc_test.h"
#include "test/arena_util.h"
+#include "test/san.h"
#include "jemalloc/internal/cache_bin.h"
+#include "jemalloc/internal/san.h"
#include "jemalloc/internal/safety_check.h"
+const char *malloc_conf = TEST_SAN_UAF_ALIGN_ENABLE;
+
static size_t san_uaf_align;
static bool fake_abort_called;
@@ -28,7 +32,7 @@ test_write_after_free_post(void) {
static bool
uaf_detection_enabled(void) {
- if (!config_uaf_detection) {
+ if (!config_uaf_detection || !san_uaf_detection_enabled()) {
return false;
}
diff --git a/test/unit/uaf.sh b/test/unit/uaf.sh
deleted file mode 100644
index 5f12dcf..0000000
--- a/test/unit/uaf.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-export MALLOC_CONF="lg_san_uaf_align:12"