Move memory corruption tests up a directory

This commit is contained in:
jvoisin 2022-01-21 20:47:21 +01:00 committed by Daniel Micay
parent 0bbcc5d610
commit 84eadd8568
42 changed files with 83 additions and 140 deletions

View File

@ -9,8 +9,12 @@ ifeq (,$(filter $(CONFIG_SLAB_CANARY),true false))
$(error CONFIG_SLAB_CANARY must be true or false)
endif
LDLIBS := -lpthread
LDLIBS := -lpthread -lhardened_malloc
dir=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
LDFLAGS := -Wl,-L$(dir)../out,-R,$(dir)../out
CXXFLAGS := -std=c++17 -fsized-deallocation
CPPFLAGS += \
-DSLAB_CANARY=$(CONFIG_SLAB_CANARY) \
-DCONFIG_EXTENDED_SIZE_CLASSES=$(CONFIG_EXTENDED_SIZE_CLASSES)
@ -20,11 +24,47 @@ EXECUTABLES := \
mallinfo \
mallinfo2 \
malloc_info \
large_array_growth
large_array_growth \
double_free_large \
double_free_large_delayed \
double_free_small \
double_free_small_delayed \
unaligned_free_large \
unaligned_free_small \
read_after_free_large \
read_after_free_small \
write_after_free_large \
write_after_free_large_reuse \
write_after_free_small \
write_after_free_small_reuse \
read_zero_size \
write_zero_size \
invalid_free_protected \
invalid_free_unprotected \
invalid_free_small_region \
invalid_free_small_region_far \
uninitialized_read_small \
uninitialized_read_large \
uninitialized_free \
uninitialized_realloc \
uninitialized_malloc_usable_size \
overflow_large_1_byte \
overflow_large_8_byte \
overflow_small_1_byte \
overflow_small_8_byte \
string_overflow \
delete_type_size_mismatch \
unaligned_malloc_usable_size_small \
invalid_malloc_usable_size_small \
invalid_malloc_usable_size_small_quarantine \
malloc_object_size \
malloc_object_size_offset \
invalid_malloc_object_size_small \
invalid_malloc_object_size_small_quarantine \
impossibly_large_malloc
all: $(EXECUTABLES)
$(MAKE) -C simple-memory-corruption
clean:
rm -f $(EXECUTABLES)
$(MAKE) -C simple-memory-corruption clean

View File

@ -1,6 +1,6 @@
#include <stdint.h>
#include "../test_util.h"
#include "test_util.h"
struct foo {
uint64_t a, b, c, d;

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
void *p = malloc(256 * 1024);

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
void *p = malloc(256 * 1024);

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
void *p = malloc(16);

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
void *p = malloc(16);

View File

@ -1,7 +1,7 @@
#include <malloc.h>
#include <stddef.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(-8);

View File

@ -2,7 +2,7 @@
#include <sys/mman.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
free(malloc(16));

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(16);

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(16);

View File

@ -2,7 +2,7 @@
#include <sys/mman.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
free(malloc(16));

View File

@ -1,6 +1,6 @@
#include <malloc.h>
#include "../test_util.h"
#include "test_util.h"
size_t malloc_object_size(void *ptr);

View File

@ -1,6 +1,6 @@
#include <malloc.h>
#include "../test_util.h"
#include "test_util.h"
size_t malloc_object_size(void *ptr);

View File

@ -1,6 +1,6 @@
#include <malloc.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(16);

View File

@ -1,6 +1,6 @@
#include <malloc.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
void *p = malloc(16);

View File

@ -1,7 +1,7 @@
#include <stdbool.h>
#include <malloc.h>
#include "../test_util.h"
#include "test_util.h"
size_t malloc_object_size(void *ptr);

View File

@ -1,7 +1,7 @@
#include <stdbool.h>
#include <malloc.h>
#include "../test_util.h"
#include "test_util.h"
size_t malloc_object_size(void *ptr);

View File

@ -1,7 +1,7 @@
#include <malloc.h>
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(256 * 1024);

View File

@ -1,7 +1,7 @@
#include <malloc.h>
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(256 * 1024);

View File

@ -1,7 +1,7 @@
#include <malloc.h>
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(8);

View File

@ -1,7 +1,7 @@
#include <malloc.h>
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(8);

View File

@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(256 * 1024);

View File

@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(16);

View File

@ -1,7 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(0);

View File

@ -1,38 +0,0 @@
delete_type_size_mismatch
double_free_large
double_free_large_delayed
double_free_small
double_free_small_delayed
invalid_free_protected
invalid_free_small_region
invalid_free_small_region_far
invalid_free_unprotected
read_after_free_large
read_after_free_small
read_zero_size
string_overflow
unaligned_free_large
unaligned_free_small
uninitialized_free
uninitialized_malloc_usable_size
uninitialized_realloc
write_after_free_large
write_after_free_large_reuse
write_after_free_small
write_after_free_small_reuse
write_zero_size
unaligned_malloc_usable_size_small
invalid_malloc_usable_size_small
invalid_malloc_usable_size_small_quarantine
malloc_object_size
malloc_object_size_offset
invalid_malloc_object_size_small
invalid_malloc_object_size_small_quarantine
impossibly_large_malloc
overflow_large_1_byte
overflow_large_8_byte
overflow_small_1_byte
overflow_small_8_byte
uninitialized_read_large
uninitialized_read_small
__pycache__/

View File

@ -1,59 +0,0 @@
dir=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
CONFIG_SLAB_CANARY := true
CXXFLAGS := -std=c++17 -fsized-deallocation
ifeq (,$(filter $(CONFIG_SLAB_CANARY),true false))
$(error CONFIG_SLAB_CANARY must be true or false)
endif
CPPFLAGS += -D_GNU_SOURCE \
-DSLAB_CANARY=$(CONFIG_SLAB_CANARY)
LDLIBS := -lhardened_malloc
LDFLAGS := -Wl,-L$(dir)../../out,-R,$(dir)../../out
EXECUTABLES := \
double_free_large \
double_free_large_delayed \
double_free_small \
double_free_small_delayed \
unaligned_free_large \
unaligned_free_small \
read_after_free_large \
read_after_free_small \
write_after_free_large \
write_after_free_large_reuse \
write_after_free_small \
write_after_free_small_reuse \
read_zero_size \
write_zero_size \
invalid_free_protected \
invalid_free_unprotected \
invalid_free_small_region \
invalid_free_small_region_far \
uninitialized_read_small \
uninitialized_read_large \
uninitialized_free \
uninitialized_realloc \
uninitialized_malloc_usable_size \
overflow_large_1_byte \
overflow_large_8_byte \
overflow_small_1_byte \
overflow_small_8_byte \
string_overflow \
delete_type_size_mismatch \
unaligned_malloc_usable_size_small \
invalid_malloc_usable_size_small \
invalid_malloc_usable_size_small_quarantine \
malloc_object_size \
malloc_object_size_offset \
invalid_malloc_object_size_small \
invalid_malloc_object_size_small_quarantine \
impossibly_large_malloc
all: $(EXECUTABLES)
clean:
rm -f $(EXECUTABLES)

View File

@ -4,7 +4,7 @@
#include <malloc.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(16);

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(256 * 1024);

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(16);

View File

@ -1,6 +1,6 @@
#include <malloc.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(16);

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
free((void *)1);

View File

@ -1,6 +1,6 @@
#include <malloc.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
malloc_usable_size((void *)1);

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(256 * 1024);

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(8);

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
void *p = realloc((void *)1, 16);

View File

@ -1,7 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(256 * 1024);

View File

@ -1,8 +1,8 @@
#include <stdlib.h>
#include <string.h>
#include "../test_util.h"
#include "../../util.h"
#include "test_util.h"
#include "../util.h"
OPTNONE int main(void) {
char *p = malloc(256 * 1024);

View File

@ -1,7 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(128);

View File

@ -1,8 +1,8 @@
#include <stdlib.h>
#include <string.h>
#include "../test_util.h"
#include "../../util.h"
#include "test_util.h"
#include "../util.h"
OPTNONE int main(void) {
char *p = malloc(128);

View File

@ -1,7 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "../test_util.h"
#include "test_util.h"
OPTNONE int main(void) {
char *p = malloc(0);