LINUX: Always hold afs_xuser for unixuser read
authorAndrew Deason <adeason@sinenomine.net>
Tue, 31 Jul 2012 18:40:41 +0000 (14:40 -0400)
committerDerrick Brashear <shadow@dementix.org>
Tue, 31 Jul 2012 19:44:17 +0000 (12:44 -0700)
We were failing to hold the afs_xuser lock when we entered our
unixuser traversal for the first time (when the given position is 0).
This means we can release the lock without acquiring it, causing all
kinds of weird behavior.

Just always grab afs_xuser on entry. We could possibly do some tricks
to avoid grabbing this lock until after we've printed the column
headers, but it does not seem worth it.

Change-Id: I68782098b5af2feb56887bc577511da2983d4f21
Reviewed-on: http://gerrit.openafs.org/7916
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

src/afs/LINUX/osi_proc.c

index bb1529b..b5219fa 100644 (file)
@@ -138,12 +138,14 @@ uu_start(struct seq_file *m, loff_t *pos)
     loff_t n = 0;
     afs_int32 i;
 
-    if (!*pos)
-       return (void *)(1);
-
     AFS_GLOCK();
     ObtainReadLock(&afs_xuser);
 
+    if (!*pos) {
+       ret = (void *)(1);
+       goto done;
+    }
+
     ret = NULL;
 
     for (i = 0; i < NUSERS; i++) {