git: 68a3a7fc9483 - main - kasan: fix false-positive kasan_report upon thread reuse
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 19 Apr 2024 19:18:44 UTC
The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=68a3a7fc94833020403190c20bd9be186c6156ce commit 68a3a7fc94833020403190c20bd9be186c6156ce Author: Ka Ho Ng <khng@FreeBSD.org> AuthorDate: 2024-04-19 19:18:27 +0000 Commit: Ka Ho Ng <khng@FreeBSD.org> CommitDate: 2024-04-19 19:18:27 +0000 kasan: fix false-positive kasan_report upon thread reuse In fork1(), if a thread is reused and thread_alloc_stack() is not called, mark the reused thread's kstack pages clean in the KASAN shadow buffer. Sponsored by: Juniper Networks, Inc. MFC after: 3 days Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44875 --- sys/kern/kern_fork.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index c7b2b1195841..d0044dfc19a0 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -40,6 +40,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/asan.h> #include <sys/bitstring.h> #include <sys/sysproto.h> #include <sys/eventhandler.h> @@ -1026,6 +1027,10 @@ fork1(struct thread *td, struct fork_req *fr) error = ENOMEM; goto fail2; } + } else { + kasan_mark((void *)td2->td_kstack, + ptoa(td2->td_kstack_pages), + ptoa(td2->td_kstack_pages), 0); } }