Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Oct 2021 20:09:53 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 880b670c6fdb - main - malloc: Unmark KASAN redzones if the full allocation size was requested
Message-ID:  <202110062009.196K9rJY069527@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=880b670c6fdbd1268887869375771e0a74d2c8ac

commit 880b670c6fdbd1268887869375771e0a74d2c8ac
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-10-06 20:03:30 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-10-06 20:09:41 +0000

    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
---
 sys/kern/kern_malloc.c | 7 +++++++
 1 file changed, 7 insertions(+)

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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202110062009.196K9rJY069527>