From 28c791484db2f09a45994da61e13a0ca8c8fe4db Mon Sep 17 00:00:00 2001 From: pho Date: Fri, 16 Dec 2011 12:53:15 +0000 Subject: [PATCH] MFC: r228360 Move cpu_set_upcall(newtd, td) up before the first call of thread_free(newtd). This to avoid a possible page fault in cpu_thread_clean() as seen on amd64 with syscall fuzzing. git-svn-id: svn://svn.freebsd.org/base/stable/8@228573 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/kern/kern_thr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index 49f961939..25a2b6ef7 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -188,6 +188,8 @@ create_thread(struct thread *td, mcontext_t *ctx, if (newtd == NULL) return (ENOMEM); + cpu_set_upcall(newtd, td); + /* * Try the copyout as soon as we allocate the td so we don't * have to tear things down in a failure case below. @@ -215,8 +217,6 @@ create_thread(struct thread *td, mcontext_t *ctx, newtd->td_proc = td->td_proc; newtd->td_ucred = crhold(td->td_ucred); - cpu_set_upcall(newtd, td); - if (ctx != NULL) { /* old way to set user context */ error = set_mcontext(newtd, ctx); if (error != 0) { -- 2.45.0