Skip to content

eBPF-based security platform

malloc: declare what it poisons before poisoning it

Daniel Borkmann338dd673ac34
diff --git a/testing/fuzz/fuzz-beefile.c b/testing/fuzz/fuzz-beefile.c
index bf4f455c..082cb322 100644
--- a/testing/fuzz/fuzz-beefile.c
+++ b/testing/fuzz/fuzz-beefile.c
@@ -9,12 +9,11 @@
#include <errno.h>
#include "fuzz.h"
+#include "malloc.h"
#include "tools/shirudo-build/bpm.h"
#include "tools/shirudo-build/compile.h"
#include "tools/shirudo-build/package.h"
#include "tools/shirudo-build/vmlinux.h"
-/* Last: it poisons the libc allocators the headers above declare. */
-#include "malloc.h"
/* What bpm build does with a parsed Beefile is out of reach from here. */
int shirudo_build_bpm_push(int argc, char **argv)
diff --git a/util/malloc.h b/util/malloc.h
index a104bb1a..f8122e0f 100644
--- a/util/malloc.h
+++ b/util/malloc.h
@@ -9,6 +9,9 @@
#define SHIRUDO_MALLOC_H
#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
/*
* NULL on failure, never die(): a one-shot CLI reports -ENOMEM up its
@@ -58,8 +61,8 @@ void xstrfree(char *s);
void libc_free(void *p);
/*
- * The poison sits at the end so that the system declarations pulled in
- * earlier are processed first; util/malloc.c opts out with
+ * Refused once the headers included above have declared them, so that a
+ * later include of those still works; util/malloc.c opts out with
* SHIRUDO_MALLOC_INTERNAL.
*/
#ifndef SHIRUDO_MALLOC_INTERNAL