From 5dda15adbcf7b650fb69b5259090b16c66d1cf1a Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Tue, 10 Aug 2021 20:58:00 -0400 Subject: kern: Ensure that thread-local KMSAN state is available Sponsored by: The FreeBSD Foundation --- sys/kern/kern_fork.c | 2 ++ sys/kern/kern_thread.c | 3 +++ 2 files changed, 5 insertions(+) (limited to 'sys/kern') diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 7a80f7de85d8..b71a00adb62e 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -958,6 +959,7 @@ fork1(struct thread *td, struct fork_req *fr) } proc_linkup(newproc, td2); } else { + kmsan_thread_alloc(td2); if (td2->td_kstack == 0 || td2->td_kstack_pages != pages) { if (td2->td_kstack != 0) vm_thread_dispose(td2); diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 28a517e9b35e..cb35d565974d 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -761,6 +762,7 @@ thread_alloc(int pages) return (NULL); } td->td_tid = tid; + kmsan_thread_alloc(td); cpu_thread_alloc(td); EVENTHANDLER_DIRECT_INVOKE(thread_ctor, td); return (td); @@ -797,6 +799,7 @@ thread_free_batched(struct thread *td) * Freeing handled by the caller. */ td->td_tid = -1; + kmsan_thread_free(td); uma_zfree(thread_zone, td); } -- cgit v1.2.3