malloc: Unmark KASAN redzones if the full allocation size was requested

Consumers that want the full allocation size will typically access the
full buffer, so mark the entire allocation as valid to avoid useless
KASAN reports.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Mark Johnston 2021-10-06 16:03:30 -04:00
parent 032a5bd55b
commit 880b670c6f

View File

@ -1112,6 +1112,13 @@ malloc_usable_size(const void *addr)
else
size = malloc_large_size(slab);
#endif
/*
* Unmark the redzone to avoid reports from consumers who are
* (presumably) about to use the full allocation size.
*/
kasan_mark(addr, size, size, 0);
return (size);
}