diff options
author | Mark Johnston <markj@FreeBSD.org> | 2021-04-13 21:39:55 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2021-04-13 21:42:21 +0000 |
commit | 244f3ec642ed99a371c97b946b93b877d8be1756 (patch) | |
tree | 2fdf604d29fbe3e31661f8c0580d75f85e312e72 | |
parent | 09c8cb717d214d03e51b3e4f8e9997b9f4e1624d (diff) | |
download | src-244f3ec642ed99a371c97b946b93b877d8be1756.tar.gz src-244f3ec642ed99a371c97b946b93b877d8be1756.zip |
kstack: Add KASAN state transitions
We allocate kernel stacks using a UMA cache zone. Cache zones have
KASAN disabled by default, but in this case it makes sense to enable it.
Reviewed by: andrew
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29457
-rw-r--r-- | sys/vm/vm_glue.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index a2500828eae4..6facf744456c 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> +#include <sys/asan.h> #include <sys/domainset.h> #include <sys/limits.h> #include <sys/lock.h> @@ -86,7 +87,6 @@ __FBSDID("$FreeBSD$"); #include <sys/vmem.h> #include <sys/sx.h> #include <sys/sysctl.h> -#include <sys/eventhandler.h> #include <sys/kernel.h> #include <sys/ktr.h> #include <sys/unistd.h> @@ -351,6 +351,7 @@ vm_thread_stack_dispose(vm_offset_t ks, int pages) vm_page_free(m); } VM_OBJECT_WUNLOCK(kstack_object); + kasan_mark((void *)ks, ptoa(pages), ptoa(pages), 0); kva_free(ks - (KSTACK_GUARD_PAGES * PAGE_SIZE), (pages + KSTACK_GUARD_PAGES) * PAGE_SIZE); } @@ -385,6 +386,7 @@ vm_thread_new(struct thread *td, int pages) return (0); td->td_kstack = ks; td->td_kstack_pages = pages; + kasan_mark((void *)ks, ptoa(pages), ptoa(pages), 0); return (1); } @@ -401,6 +403,7 @@ vm_thread_dispose(struct thread *td) ks = td->td_kstack; td->td_kstack = 0; td->td_kstack_pages = 0; + kasan_mark((void *)ks, 0, ptoa(pages), KASAN_KSTACK_FREED); if (pages == kstack_pages) uma_zfree(kstack_cache, (void *)ks); else |