Revert "QASan: remove chunk_struct (#2899)" (#2928)

This reverts commit ba0da5121b54c89d5ad3c06189959afbbeb64d23.
This commit is contained in:
Dominik Maier 2025-02-03 14:47:13 +01:00 committed by GitHub
parent 500e01816d
commit 5bd6a6f754
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -63,6 +63,13 @@ struct chunk_begin {
} __attribute__((packed)); } __attribute__((packed));
struct chunk_struct {
struct chunk_begin begin;
char redzone[REDZONE_SIZE];
size_t prev_size_padding;
} __attribute__((packed));
#ifdef USE_LIBC_ALLOC #ifdef USE_LIBC_ALLOC
void *(*__lq_libc_memalign)(size_t, size_t); void *(*__lq_libc_memalign)(size_t, size_t);
@ -170,14 +177,14 @@ void *__libqasan_malloc(size_t size) {
struct chunk_begin *p = backend_memalign( struct chunk_begin *p = backend_memalign(
ALLOC_ALIGN_SIZE, ALLOC_ALIGN_SIZE,
sizeof(struct chunk_begin) + qasan_align_up(size, ALLOC_ALIGN_SIZE)); sizeof(struct chunk_struct) + qasan_align_up(size, ALLOC_ALIGN_SIZE));
QASAN_SWAP(state); QASAN_SWAP(state);
if (!p) return NULL; if (!p) return NULL;
QASAN_UNPOISON( QASAN_UNPOISON(
p, sizeof(struct chunk_begin) + qasan_align_up(size, ALLOC_ALIGN_SIZE)); p, sizeof(struct chunk_struct) + qasan_align_up(size, ALLOC_ALIGN_SIZE));
p->requested_size = size; p->requested_size = size;
p->aligned_orig = NULL; p->aligned_orig = NULL;
@ -274,13 +281,13 @@ int __libqasan_posix_memalign(void **ptr, size_t align, size_t len) {
char *orig = backend_memalign( char *orig = backend_memalign(
ALLOC_ALIGN_SIZE, ALLOC_ALIGN_SIZE,
sizeof(struct chunk_begin) + qasan_align_up(size, ALLOC_ALIGN_SIZE)); sizeof(struct chunk_struct) + qasan_align_up(size, ALLOC_ALIGN_SIZE));
QASAN_SWAP(state); QASAN_SWAP(state);
if (!orig) return ENOMEM; if (!orig) return ENOMEM;
QASAN_UNPOISON(orig, sizeof(struct chunk_begin) + QASAN_UNPOISON(orig, sizeof(struct chunk_struct) +
qasan_align_up(size, ALLOC_ALIGN_SIZE)); qasan_align_up(size, ALLOC_ALIGN_SIZE));
char *data = orig + sizeof(struct chunk_begin); char *data = orig + sizeof(struct chunk_begin);