diff options
author | tanimura <tanimura@FreeBSD.org> | 2002-04-20 12:02:52 +0000 |
---|---|---|
committer | tanimura <tanimura@FreeBSD.org> | 2002-04-20 12:02:52 +0000 |
commit | e2acd5cecf61f060255d467b8d38cd35f941fb1c (patch) | |
tree | db003c23254ef3cdf9c6c9bea269469378e11e7d /sys/kern/kern_prot.c | |
parent | 487a22adbf7d14b574b29683ada3bc989bbfb261 (diff) | |
download | FreeBSD-src-e2acd5cecf61f060255d467b8d38cd35f941fb1c.zip FreeBSD-src-e2acd5cecf61f060255d467b8d38cd35f941fb1c.tar.gz |
Push down Giant for setpgid(), setsid() and aio_daemon(). Giant protects only
malloc(9) and free(9).
Diffstat (limited to 'sys/kern/kern_prot.c')
-rw-r--r-- | sys/kern/kern_prot.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index b8a0156..30f8902 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -345,9 +345,9 @@ setsid(register struct thread *td, struct setsid_args *uap) pgrp = NULL; mtx_lock(&Giant); - MALLOC(newpgrp, struct pgrp *, sizeof(struct pgrp), M_PGRP, M_WAITOK | M_ZERO); MALLOC(newsess, struct session *, sizeof(struct session), M_SESSION, M_WAITOK | M_ZERO); + mtx_unlock(&Giant); sx_xlock(&proctree_lock); @@ -364,12 +364,15 @@ setsid(register struct thread *td, struct setsid_args *uap) sx_xunlock(&proctree_lock); - if (newpgrp != NULL) - FREE(newpgrp, M_PGRP); - if (newsess != NULL) - FREE(newsess, M_SESSION); + if (newpgrp != NULL || newsess != NULL) { + mtx_lock(&Giant); + if (newpgrp != NULL) + FREE(newpgrp, M_PGRP); + if (newsess != NULL) + FREE(newsess, M_SESSION); + mtx_unlock(&Giant); + } - mtx_unlock(&Giant); return (error); } @@ -411,8 +414,8 @@ setpgid(struct thread *td, register struct setpgid_args *uap) error = 0; mtx_lock(&Giant); - MALLOC(newpgrp, struct pgrp *, sizeof(struct pgrp), M_PGRP, M_WAITOK | M_ZERO); + mtx_unlock(&Giant); sx_xlock(&proctree_lock); if (uap->pid != 0 && uap->pid != curp->p_pid) { @@ -476,9 +479,11 @@ done: sx_xunlock(&proctree_lock); KASSERT((error == 0) || (newpgrp != NULL), ("setpgid failed and newpgrp is NULL")); - if (newpgrp != NULL) + if (newpgrp != NULL) { + mtx_lock(&Giant); FREE(newpgrp, M_PGRP); - mtx_unlock(&Giant); + mtx_unlock(&Giant); + } return (error); } @@ -1808,7 +1813,6 @@ getlogin(struct thread *td, struct getlogin_args *uap) char login[MAXLOGNAME]; struct proc *p = td->td_proc; - mtx_lock(&Giant); if (uap->namelen > MAXLOGNAME) uap->namelen = MAXLOGNAME; PROC_LOCK(p); @@ -1817,7 +1821,6 @@ getlogin(struct thread *td, struct getlogin_args *uap) SESS_UNLOCK(p->p_session); PROC_UNLOCK(p); error = copyout((caddr_t) login, (caddr_t) uap->namebuf, uap->namelen); - mtx_unlock(&Giant); return(error); } |