From: Nickolai Zeldovich Date: Tue, 2 Apr 2002 03:06:32 +0000 (+0000) Subject: STABLE12-solaris-p-crlock-not-safe-to-hold-across-call-to-crset-20020206 X-Git-Tag: openafs-stable-1_2_4~81 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=2c8646ca450b703667ae4ffdc2271a1c93d00ca6;p=packages%2Fo%2Fopenafs.git STABLE12-solaris-p-crlock-not-safe-to-hold-across-call-to-crset-20020206 crset() expects p_crlock to not be held when it's called; deal accordingly (cherry picked from commit e7b3045d8ece68712d2bd07b8e92c90027dee870) --- diff --git a/src/afs/SOLARIS/osi_groups.c b/src/afs/SOLARIS/osi_groups.c index 37be48361..86b25187c 100644 --- a/src/afs/SOLARIS/osi_groups.c +++ b/src/afs/SOLARIS/osi_groups.c @@ -91,6 +91,8 @@ setpag(cred, pagvalue, newpag, change_parent) AFS_STATCNT(setpag); gidset = (gid_t *) osi_AllocSmallSpace(AFS_SMALLOCSIZ); + + mutex_enter(&curproc->p_crlock); ngroups = afs_getgroups(*cred, gidset); if (afs_get_pag_from_groups(gidset[0], gidset[1]) == NOPAG) { @@ -106,6 +108,7 @@ setpag(cred, pagvalue, newpag, change_parent) } *newpag = (pagvalue == -1 ? genpag(): pagvalue); afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]); + /* afs_setgroups will release curproc->p_crlock */ if (code = afs_setgroups(cred, ngroups, gidset, change_parent)) { osi_FreeSmallSpace((char *)gidset); return (code); @@ -148,17 +151,18 @@ afs_setgroups( AFS_STATCNT(afs_setgroups); - if (ngroups > ngroups_max) + if (ngroups > ngroups_max) { + mutex_exit(&curproc->p_crlock); return EINVAL; + } if (!change_parent) *cred = (struct cred *)crcopy(*cred); (*cred)->cr_ngroups = ngroups; gp = (*cred)->cr_groups; while (ngroups--) *gp++ = *gidset++; - if (!change_parent) { - struct proc *proc = ttoproc(curthread); - crset(proc, *cred); /* broadcast to all threads */ - } + mutex_exit(&curproc->p_crlock); + if (!change_parent) + crset(curproc, *cred); /* broadcast to all threads */ return (0); } diff --git a/src/afs/afs_call.c b/src/afs/afs_call.c index 924dec466..1e90d4153 100644 --- a/src/afs/afs_call.c +++ b/src/afs/afs_call.c @@ -1072,17 +1072,12 @@ Afs_syscall () #endif } else if (uap->syscall == AFSCALL_SETPAG) { #ifdef AFS_SUN5_ENV - struct cred *cred; register proc_t *procp; procp = ttoproc(curthread); - mutex_enter(&procp->p_crlock); - cred = procp->p_cred; AFS_GLOCK(); - code = afs_setpag(&cred); + code = afs_setpag(&procp->p_cred); AFS_GUNLOCK(); - procp->p_cred = cred; - mutex_exit(&procp->p_crlock); #else AFS_GLOCK(); #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)