]> git.droids-corp.org - dpdk.git/commit
malloc: fix ASan handling for unmapped memory
authorAnatoly Burakov <anatoly.burakov@intel.com>
Wed, 4 May 2022 14:31:58 +0000 (14:31 +0000)
committerDavid Marchand <david.marchand@redhat.com>
Thu, 5 May 2022 08:13:43 +0000 (10:13 +0200)
commit4d8bdd8b56a102fbe7d8ca167d5044625f4dbb32
treef29268a0205b376c16fd855992f2ae7023e7d40f
parent90bf3f89ed33f78e9f41818caf123e13e508dee7
malloc: fix ASan handling for unmapped memory

Currently, when we free previously allocated memory, we mark the area as
"freed" for ASan purposes (flag 0xfd). However, sometimes, freeing a
malloc element will cause pages to be unmapped from memory and re-backed
with anonymous memory again. This may cause ASan's "use-after-free"
error down the line, because the allocator will try to write into
memory areas recently marked as "freed".

To fix this, we need to mark the unmapped memory area as "available",
and fixup surrounding malloc element header/trailers to enable later
malloc routines to safely write into new malloc elements' headers or
trailers.

Bugzilla ID: 994
Fixes: 6cc51b1293ce ("mem: instrument allocator for ASan")
Cc: stable@dpdk.org
Reported-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
lib/eal/common/malloc_elem.h
lib/eal/common/malloc_heap.c