git: a932a5a64982 - main - uma: Mark zeroed slabs as initialized for KMSAN

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 20 Jun 2022 17:00:27 UTC
The branch main has been updated by markj:

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

commit a932a5a649823fda05e89f7757cc59339da8e2aa
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-06-20 15:50:54 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-06-20 16:48:13 +0000

    uma: Mark zeroed slabs as initialized for KMSAN
    
    Otherwise zone initializers can produce false positives, e.g., when
    lock_init() attempts to detect double initialization.
    
    Sponsored by:   The FreeBSD Foundation
---
 sys/vm/uma_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index dfa3138a34f9..8502719cac72 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -1805,6 +1805,9 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int domain, int flags,
 	if ((keg->uk_flags & UMA_ZFLAG_HASH) != 0)
 		domain = 0;
 
+	kmsan_mark(mem, size,
+	    (aflags & M_ZERO) != 0 ? KMSAN_STATE_INITED : KMSAN_STATE_UNINIT);
+
 	/* Point the slab into the allocated memory */
 	if (!(keg->uk_flags & UMA_ZFLAG_OFFPAGE))
 		slab = (uma_slab_t)(mem + keg->uk_pgoff);