Skip to content

Commit

Permalink
QASan: remove chunk_struct (#2899)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmalmain authored Jan 28, 2025
1 parent b320a8d commit ba0da51
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions libafl_qemu/libqasan/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ struct chunk_begin {

} __attribute__((packed));

struct chunk_struct {
struct chunk_begin begin;
char redzone[REDZONE_SIZE];
size_t prev_size_padding;

} __attribute__((packed));

#ifdef USE_LIBC_ALLOC

void *(*__lq_libc_memalign)(size_t, size_t);
Expand Down Expand Up @@ -177,14 +170,14 @@ void *__libqasan_malloc(size_t size) {

struct chunk_begin *p = backend_memalign(
ALLOC_ALIGN_SIZE,
sizeof(struct chunk_struct) + qasan_align_up(size, ALLOC_ALIGN_SIZE));
sizeof(struct chunk_begin) + qasan_align_up(size, ALLOC_ALIGN_SIZE));

QASAN_SWAP(state);

if (!p) return NULL;

QASAN_UNPOISON(
p, sizeof(struct chunk_struct) + qasan_align_up(size, ALLOC_ALIGN_SIZE));
p, sizeof(struct chunk_begin) + qasan_align_up(size, ALLOC_ALIGN_SIZE));

p->requested_size = size;
p->aligned_orig = NULL;
Expand Down Expand Up @@ -281,13 +274,13 @@ int __libqasan_posix_memalign(void **ptr, size_t align, size_t len) {

char *orig = backend_memalign(
ALLOC_ALIGN_SIZE,
sizeof(struct chunk_struct) + qasan_align_up(size, ALLOC_ALIGN_SIZE));
sizeof(struct chunk_begin) + qasan_align_up(size, ALLOC_ALIGN_SIZE));

QASAN_SWAP(state);

if (!orig) return ENOMEM;

QASAN_UNPOISON(orig, sizeof(struct chunk_struct) +
QASAN_UNPOISON(orig, sizeof(struct chunk_begin) +
qasan_align_up(size, ALLOC_ALIGN_SIZE));

char *data = orig + sizeof(struct chunk_begin);
Expand Down

0 comments on commit ba0da51

Please sign in to comment.