From 52c3844c7a23eda4d1d85009c45a8027dac3f862 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 1 May 2003 21:21:42 +0000 Subject: [PATCH] Remove Giant from the setuid(), seteuid(), setgid(), setegid(), setgroups(), setreuid(), setregid(), setresuid(), and setresgid() syscalls as well as the cred_update_thread() function. --- sys/kern/kern_prot.c | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index b953553b90cf..c9c62e952bec 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -496,7 +496,6 @@ setuid(struct thread *td, struct setuid_args *uap) struct uidinfo *uip; int error; - mtx_lock(&Giant); uid = uap->uid; newcred = crget(); uip = uifind(uid); @@ -531,7 +530,6 @@ setuid(struct thread *td, struct setuid_args *uap) PROC_UNLOCK(p); uifree(uip); crfree(newcred); - mtx_unlock(&Giant); return (error); } @@ -582,7 +580,6 @@ setuid(struct thread *td, struct setuid_args *uap) PROC_UNLOCK(p); uifree(uip); crfree(oldcred); - mtx_unlock(&Giant); return (0); } @@ -605,7 +602,6 @@ seteuid(struct thread *td, struct seteuid_args *uap) int error; euid = uap->euid; - mtx_lock(&Giant); newcred = crget(); euip = uifind(euid); PROC_LOCK(p); @@ -616,7 +612,6 @@ seteuid(struct thread *td, struct seteuid_args *uap) PROC_UNLOCK(p); uifree(euip); crfree(newcred); - mtx_unlock(&Giant); return (error); } /* @@ -632,7 +627,6 @@ seteuid(struct thread *td, struct seteuid_args *uap) PROC_UNLOCK(p); uifree(euip); crfree(oldcred); - mtx_unlock(&Giant); return (0); } @@ -654,7 +648,6 @@ setgid(struct thread *td, struct setgid_args *uap) int error; gid = uap->gid; - mtx_lock(&Giant); newcred = crget(); PROC_LOCK(p); oldcred = p->p_ucred; @@ -680,7 +673,6 @@ setgid(struct thread *td, struct setgid_args *uap) (error = suser_cred(oldcred, PRISON_ROOT)) != 0) { PROC_UNLOCK(p); crfree(newcred); - mtx_unlock(&Giant); return (error); } @@ -727,7 +719,6 @@ setgid(struct thread *td, struct setgid_args *uap) p->p_ucred = newcred; PROC_UNLOCK(p); crfree(oldcred); - mtx_unlock(&Giant); return (0); } @@ -749,7 +740,6 @@ setegid(struct thread *td, struct setegid_args *uap) int error; egid = uap->egid; - mtx_lock(&Giant); newcred = crget(); PROC_LOCK(p); oldcred = p->p_ucred; @@ -758,7 +748,6 @@ setegid(struct thread *td, struct setegid_args *uap) (error = suser_cred(oldcred, PRISON_ROOT)) != 0) { PROC_UNLOCK(p); crfree(newcred); - mtx_unlock(&Giant); return (error); } crcopy(newcred, oldcred); @@ -769,7 +758,6 @@ setegid(struct thread *td, struct setegid_args *uap) p->p_ucred = newcred; PROC_UNLOCK(p); crfree(oldcred); - mtx_unlock(&Giant); return (0); } @@ -794,12 +782,10 @@ setgroups(struct thread *td, struct setgroups_args *uap) ngrp = uap->gidsetsize; if (ngrp > NGROUPS) return (EINVAL); - mtx_lock(&Giant); tempcred = crget(); error = copyin(uap->gidset, tempcred->cr_groups, ngrp * sizeof(gid_t)); if (error != 0) { crfree(tempcred); - mtx_unlock(&Giant); return (error); } newcred = crget(); @@ -810,7 +796,6 @@ setgroups(struct thread *td, struct setgroups_args *uap) PROC_UNLOCK(p); crfree(newcred); crfree(tempcred); - mtx_unlock(&Giant); return (error); } @@ -837,7 +822,6 @@ setgroups(struct thread *td, struct setgroups_args *uap) PROC_UNLOCK(p); crfree(tempcred); crfree(oldcred); - mtx_unlock(&Giant); return (0); } @@ -862,7 +846,6 @@ setreuid(register struct thread *td, struct setreuid_args *uap) euid = uap->euid; ruid = uap->ruid; - mtx_lock(&Giant); newcred = crget(); euip = uifind(euid); ruip = uifind(ruid); @@ -877,7 +860,6 @@ setreuid(register struct thread *td, struct setreuid_args *uap) uifree(ruip); uifree(euip); crfree(newcred); - mtx_unlock(&Giant); return (error); } crcopy(newcred, oldcred); @@ -899,7 +881,6 @@ setreuid(register struct thread *td, struct setreuid_args *uap) uifree(ruip); uifree(euip); crfree(oldcred); - mtx_unlock(&Giant); return (0); } @@ -923,7 +904,6 @@ setregid(register struct thread *td, struct setregid_args *uap) egid = uap->egid; rgid = uap->rgid; - mtx_lock(&Giant); newcred = crget(); PROC_LOCK(p); oldcred = p->p_ucred; @@ -934,7 +914,6 @@ setregid(register struct thread *td, struct setregid_args *uap) (error = suser_cred(oldcred, PRISON_ROOT)) != 0) { PROC_UNLOCK(p); crfree(newcred); - mtx_unlock(&Giant); return (error); } @@ -955,7 +934,6 @@ setregid(register struct thread *td, struct setregid_args *uap) p->p_ucred = newcred; PROC_UNLOCK(p); crfree(oldcred); - mtx_unlock(&Giant); return (0); } @@ -987,7 +965,6 @@ setresuid(register struct thread *td, struct setresuid_args *uap) euid = uap->euid; ruid = uap->ruid; suid = uap->suid; - mtx_lock(&Giant); newcred = crget(); euip = uifind(euid); ruip = uifind(ruid); @@ -1007,7 +984,6 @@ setresuid(register struct thread *td, struct setresuid_args *uap) uifree(ruip); uifree(euip); crfree(newcred); - mtx_unlock(&Giant); return (error); } @@ -1029,7 +1005,6 @@ setresuid(register struct thread *td, struct setresuid_args *uap) uifree(ruip); uifree(euip); crfree(oldcred); - mtx_unlock(&Giant); return (0); } @@ -1060,7 +1035,6 @@ setresgid(register struct thread *td, struct setresgid_args *uap) egid = uap->egid; rgid = uap->rgid; sgid = uap->sgid; - mtx_lock(&Giant); newcred = crget(); PROC_LOCK(p); oldcred = p->p_ucred; @@ -1076,7 +1050,6 @@ setresgid(register struct thread *td, struct setresgid_args *uap) (error = suser_cred(oldcred, PRISON_ROOT)) != 0) { PROC_UNLOCK(p); crfree(newcred); - mtx_unlock(&Giant); return (error); } @@ -1096,7 +1069,6 @@ setresgid(register struct thread *td, struct setresgid_args *uap) p->p_ucred = newcred; PROC_UNLOCK(p); crfree(oldcred); - mtx_unlock(&Giant); return (0); } @@ -1822,13 +1794,11 @@ cred_update_thread(struct thread *td) p = td->td_proc; cred = td->td_ucred; - mtx_lock(&Giant); PROC_LOCK(p); td->td_ucred = crhold(p->p_ucred); PROC_UNLOCK(p); if (cred != NULL) crfree(cred); - mtx_unlock(&Giant); } /*