From nobody Mon Nov 01 14:33:00 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7AE66182D8A9; Mon, 1 Nov 2021 14:33:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hjb9V3V1Mz3s1J; Mon, 1 Nov 2021 14:33:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5FEEA13612; Mon, 1 Nov 2021 14:33:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1A1EX06M021361; Mon, 1 Nov 2021 14:33:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1A1EX0Ux021359; Mon, 1 Nov 2021 14:33:00 GMT (envelope-from git) Date: Mon, 1 Nov 2021 14:33:00 GMT Message-Id: <202111011433.1A1EX0Ux021359@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 9d95539ffed2 - stable/13 - kstack: Add KASAN state transitions List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9d95539ffed299a8457c7c718a1fe039d6f595bd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9d95539ffed299a8457c7c718a1fe039d6f595bd commit 9d95539ffed299a8457c7c718a1fe039d6f595bd Author: Mark Johnston AuthorDate: 2021-04-13 21:39:55 +0000 Commit: Mark Johnston CommitDate: 2021-11-01 14:03:02 +0000 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 (cherry picked from commit 244f3ec642ed99a371c97b946b93b877d8be1756) --- sys/vm/vm_glue.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index be741fd40199..7cfb08246f9e 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -86,7 +87,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -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