more-linux26-cred-fixes-20050403
authorChas Williams <chas@cmf.nrl.navy.mil>
Sun, 3 Apr 2005 20:48:32 +0000 (20:48 +0000)
committerDerrick Brashear <shadow@dementia.org>
Sun, 3 Apr 2005 20:48:32 +0000 (20:48 +0000)
FIXES 18009

instead of crget() getting a groups_alloc(0) just to put it, we just fix
crref()/crdup()/afs_pioctl() to do the "right" thing

added missing task_lock()'s as well.

src/afs/LINUX/osi_cred.c
src/afs/afs_pioctl.c

index 6795d3f..a8f806c 100644 (file)
@@ -63,9 +63,6 @@ crget(void)
     CRED_UNLOCK();
 
     memset(tmp, 0, sizeof(cred_t));
-#if defined(AFS_LINUX26_ENV)
-    tmp->cr_group_info = groups_alloc(0);
-#endif
     tmp->cr_ref = 1;
     return tmp;
 }
@@ -98,15 +95,10 @@ crdup(cred_t * cr)
     tmp->cr_uid = cr->cr_uid;
     tmp->cr_ruid = cr->cr_ruid;
     tmp->cr_gid = cr->cr_gid;
-#if defined(AFS_LINUX26_ENV)
-{
-    struct group_info *old_info;
 
-    old_info = tmp->cr_group_info;
+#if defined(AFS_LINUX26_ENV)
     get_group_info(cr->cr_group_info);
     tmp->cr_group_info = cr->cr_group_info;
-    put_group_info(old_info);
-}
 #else
     memcpy(tmp->cr_groups, cr->cr_groups, NGROUPS * sizeof(gid_t));
     tmp->cr_ngroups = cr->cr_ngroups;
@@ -125,15 +117,12 @@ crref(void)
     cr->cr_ruid = current->uid;
     cr->cr_gid = current->fsgid;
     cr->cr_rgid = current->gid;
-#if defined(AFS_LINUX26_ENV)
-{
-    struct group_info *old_info;
 
-    old_info = cr->cr_group_info;
+#if defined(AFS_LINUX26_ENV)
+    task_lock(current);
     get_group_info(current->group_info);
     cr->cr_group_info = current->group_info;
-    put_group_info(old_info);
-}
+    task_unlock(current);
 #else
     memcpy(cr->cr_groups, current->groups, NGROUPS * sizeof(gid_t));
     cr->cr_ngroups = current->ngroups;
@@ -155,9 +144,13 @@ crset(cred_t * cr)
     struct group_info *old_info;
 
     /* using set_current_groups() will sort the groups */
-    old_info = current->group_info;
     get_group_info(cr->cr_group_info);
+
+    task_lock(current);
+    old_info = current->group_info;
     current->group_info = cr->cr_group_info;
+    task_unlock(current);
+
     put_group_info(old_info);
 }
 #else
index 6b508d5..2523b70 100644 (file)
@@ -3326,6 +3326,9 @@ HandleClientContext(struct afs_ioctl *ablob, int *com,
        uid = afs_nobody;       /* NFS_NOBODY == -2 */
     }
     newcred = crget();
+#if defined(AFS_LINUX26_ENV)
+    newcred->cr_group_info = groups_alloc(0);
+#endif
 #ifdef AFS_AIX41_ENV
     setuerror(0);
 #endif