From 4444375710b8ca3ba1514837f73fc507da403678 Mon Sep 17 00:00:00 2001 From: "Tim J. Robbins" Date: Sat, 15 Feb 2003 09:56:09 +0000 Subject: [PATCH] Acquire Giant around calls to kern_sigaction() in sigaction(), freebsd4_sigaction() and osigaction() instead of around the whole body of those functions. They now no longer hold Giant around calls to copyin() and copyout(), and it is slightly more obvious what Giant is protecting. --- sys/kern/kern_sig.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 99504499adb..9ca2ff40b10 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -389,7 +389,6 @@ struct sigaction_args { /* * MPSAFE */ -/* ARGSUSED */ int sigaction(td, uap) struct thread *td; @@ -399,21 +398,19 @@ sigaction(td, uap) register struct sigaction *actp, *oactp; int error; - mtx_lock(&Giant); - actp = (uap->act != NULL) ? &act : NULL; oactp = (uap->oact != NULL) ? &oact : NULL; if (actp) { error = copyin(uap->act, actp, sizeof(act)); if (error) - goto done2; + return (error); } + mtx_lock(&Giant); error = kern_sigaction(td, uap->sig, actp, oactp, 0); + mtx_unlock(&Giant); if (oactp && !error) { error = copyout(oactp, uap->oact, sizeof(oact)); } -done2: - mtx_unlock(&Giant); return (error); } @@ -428,7 +425,6 @@ struct freebsd4_sigaction_args { /* * MPSAFE */ -/* ARGSUSED */ int freebsd4_sigaction(td, uap) struct thread *td; @@ -438,21 +434,20 @@ freebsd4_sigaction(td, uap) register struct sigaction *actp, *oactp; int error; - mtx_lock(&Giant); actp = (uap->act != NULL) ? &act : NULL; oactp = (uap->oact != NULL) ? &oact : NULL; if (actp) { error = copyin(uap->act, actp, sizeof(act)); if (error) - goto done2; + return (error); } + mtx_lock(&Giant); error = kern_sigaction(td, uap->sig, actp, oactp, KSA_FREEBSD4); + mtx_unlock(&Giant); if (oactp && !error) { error = copyout(oactp, uap->oact, sizeof(oact)); } -done2: - mtx_unlock(&Giant); return (error); } #endif /* COMAPT_FREEBSD4 */ @@ -468,7 +463,6 @@ struct osigaction_args { /* * MPSAFE */ -/* ARGSUSED */ int osigaction(td, uap) struct thread *td; @@ -485,25 +479,23 @@ osigaction(td, uap) nsap = (uap->nsa != NULL) ? &nsa : NULL; osap = (uap->osa != NULL) ? &osa : NULL; - mtx_lock(&Giant); - if (nsap) { error = copyin(uap->nsa, &sa, sizeof(sa)); if (error) - goto done2; + return (error); nsap->sa_handler = sa.sa_handler; nsap->sa_flags = sa.sa_flags; OSIG2SIG(sa.sa_mask, nsap->sa_mask); } + mtx_lock(&Giant); error = kern_sigaction(td, uap->signum, nsap, osap, KSA_OSIGSET); + mtx_unlock(&Giant); if (osap && !error) { sa.sa_handler = osap->sa_handler; sa.sa_flags = osap->sa_flags; SIG2OSIG(osap->sa_mask, sa.sa_mask); error = copyout(&sa, uap->osa, sizeof(sa)); } -done2: - mtx_unlock(&Giant); return (error); }