[POWERPC] fix signal race condition

r367416 should have called save_fpu() before kern_sigprocmask to avoid
race condition

Thanks jhibbits and bdragon for pointing it out

Reviewed by:	jhibbits
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D27241
This commit is contained in:
Alfredo Dal'Ava Junior 2020-11-17 12:33:12 +00:00
parent dda1987fe5
commit 23f001f742
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=367760

View File

@ -334,8 +334,6 @@ sys_sigreturn(struct thread *td, struct sigreturn_args *uap)
if (error != 0)
return (error);
kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
/*
* Save FPU state if needed. User may have changed it on
* signal handler
@ -343,6 +341,8 @@ sys_sigreturn(struct thread *td, struct sigreturn_args *uap)
if (uc.uc_mcontext.mc_srr1 & PSL_FP)
save_fpu(td);
kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
CTR3(KTR_SIG, "sigreturn: return td=%p pc=%#x sp=%#x",
td, uc.uc_mcontext.mc_srr0, uc.uc_mcontext.mc_gpr[1]);
@ -836,8 +836,6 @@ freebsd32_sigreturn(struct thread *td, struct freebsd32_sigreturn_args *uap)
if (error != 0)
return (error);
kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
/*
* Save FPU state if needed. User may have changed it on
* signal handler
@ -845,6 +843,7 @@ freebsd32_sigreturn(struct thread *td, struct freebsd32_sigreturn_args *uap)
if (uc.uc_mcontext.mc_srr1 & PSL_FP)
save_fpu(td);
kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
CTR3(KTR_SIG, "sigreturn: return td=%p pc=%#x sp=%#x",
td, uc.uc_mcontext.mc_srr0, uc.uc_mcontext.mc_gpr[1]);