Skip to content

Commit

Permalink
kasan: fix false-positive kasan_report upon thread reuse
Browse files Browse the repository at this point in the history
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
  • Loading branch information
khng300 authored and bsdjhb committed Aug 9, 2024
2 parents c8f3b43 + 68a3a7f commit 6ff7564
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sys/kern/kern_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -1038,6 +1039,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);
}
}

Expand Down

0 comments on commit 6ff7564

Please sign in to comment.