git: 933490d3b6d4 - stable/14 - kasan: fix false-positive kasan_report upon thread reuse
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 22 Apr 2024 00:31:14 UTC
The branch stable/14 has been updated by khng:
URL: https://cgit.FreeBSD.org/src/commit/?id=933490d3b6d43f7ad1dd5d8720fb2f7774d7f26e
commit 933490d3b6d43f7ad1dd5d8720fb2f7774d7f26e
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-22 00:30:58 +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
(cherry picked from commit 68a3a7fc94833020403190c20bd9be186c6156ce)
---
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 edcd8a1f2139..9bbe7c8a8153 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -42,6 +42,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>
@@ -1028,6 +1029,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);
}
}