aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_malloc.c
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2021-10-06 20:03:30 +0000
committerMark Johnston <markj@FreeBSD.org>2021-10-06 20:09:41 +0000
commit880b670c6fdbd1268887869375771e0a74d2c8ac (patch)
tree9488da0cb4cf52b5dc55897b46a2edb0ae5a945b /sys/kern/kern_malloc.c
parent032a5bd55b3a003d3560435422a95f27f91685fe (diff)
downloadsrc-880b670c6fdbd1268887869375771e0a74d2c8ac.tar.gz
src-880b670c6fdbd1268887869375771e0a74d2c8ac.zip
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
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r--sys/kern/kern_malloc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index b1c5909db2a4..4ecdcdacce01 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -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);
}