summaryrefslogtreecommitdiff
path: root/lib/libutils/isoc/bget_malloc.c
diff options
context:
space:
mode:
authorJens Wiklander <jens.wiklander@linaro.org>2017-09-11 11:42:41 +0200
committerJérôme Forissier <jerome.forissier@linaro.org>2017-09-14 08:42:20 -0500
commite103c301ffc0e1393834c45cc64c6978ddb6ad8f (patch)
treed7ffba0a3c697319165e151cece7d354a4531e23 /lib/libutils/isoc/bget_malloc.c
parentabccd9090fb4e8b9e838ccc5deeac4f7d2c901fb (diff)
libutils: malloc: use asan_memset_unchecked()
The malloc implementation uses the new asan_memset_unchecked() function internally instead of memset() to avoid unexpected asserts when the address sanitizer is enabled. bget() tags the requested amount of memory allocated, but eventual padding etc isn't tagged so writes there from instrumented functions, for instance the normal memset(), will be caught. Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'lib/libutils/isoc/bget_malloc.c')
-rw-r--r--lib/libutils/isoc/bget_malloc.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/libutils/isoc/bget_malloc.c b/lib/libutils/isoc/bget_malloc.c
index 552fdaf5..54a146f4 100644
--- a/lib/libutils/isoc/bget_malloc.c
+++ b/lib/libutils/isoc/bget_malloc.c
@@ -100,12 +100,13 @@
#endif
#include <compiler.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <stdbool.h>
#include <malloc.h>
-#include <util.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
#include <trace.h>
+#include <util.h>
#if defined(__KERNEL__)
/* Compiling for TEE Core */
@@ -133,6 +134,11 @@ static void tag_asan_alloced(void *buf, size_t len)
asan_tag_access(buf, (uint8_t *)buf + len);
}
+static void *memset_unchecked(void *s, int c, size_t n)
+{
+ return asan_memset_unchecked(s, c, n);
+}
+
#else /*__KERNEL__*/
/* Compiling for TA */
static uint32_t malloc_lock(void)
@@ -151,6 +157,12 @@ static void tag_asan_free(void *buf __unused, size_t len __unused)
static void tag_asan_alloced(void *buf __unused, size_t len __unused)
{
}
+
+static void *memset_unchecked(void *s, int c, size_t n)
+{
+ return memset(s, c, n);
+}
+
#endif /*__KERNEL__*/
#include "bget.c" /* this is ugly, but this is bget */