Windows: CleanACLEnt requires cm_scache write locked
authorJeffrey Altman <jaltman@your-file-system.com>
Thu, 5 Apr 2012 11:38:47 +0000 (07:38 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 6 Apr 2012 15:03:50 +0000 (08:03 -0700)
Therefore, cm_FindACLCache() must be called with the cm_scache_t
write-locked and therefore cm_HaveAccessRights() must obtain a
write-lock and not a read-lock on 'aclScp'.

Change-Id: I884cd5a70a793d893999bf750264e76d436f40a2
Reviewed-on: http://gerrit.openafs.org/7049
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsd/cm_access.c
src/WINNT/afsd/cm_aclent.c

index 17c6c7c..ed29a48 100644 (file)
@@ -61,7 +61,7 @@ int cm_HaveAccessRights(struct cm_scache *scp, struct cm_user *userp, cm_req_t *
         if (aclScp != scp) {
             if (aclScp->fid.vnode < scp->fid.vnode)
                 lock_ReleaseWrite(&scp->rw);
-            lock_ObtainRead(&aclScp->rw);
+            lock_ObtainWrite(&aclScp->rw);
            didLock = 1;
             if (aclScp->fid.vnode < scp->fid.vnode)
                 lock_ObtainWrite(&scp->rw);
@@ -75,7 +75,7 @@ int cm_HaveAccessRights(struct cm_scache *scp, struct cm_user *userp, cm_req_t *
         }
     }
 
-    lock_AssertAny(&aclScp->rw);
+    lock_AssertWrite(&aclScp->rw);
 
     /* now if rights is a subset of the public rights, we're done.
      * Otherwise, if we an explicit acl entry, we're also in good shape,
@@ -140,7 +140,7 @@ int cm_HaveAccessRights(struct cm_scache *scp, struct cm_user *userp, cm_req_t *
     if (volp)
         cm_PutVolume(volp);
     if (didLock)
-        lock_ReleaseRead(&aclScp->rw);
+        lock_ReleaseWrite(&aclScp->rw);
     if (release)
         cm_ReleaseSCache(aclScp);
     return code;
index 7e870bf..494eab8 100644 (file)
@@ -66,7 +66,7 @@ static void CleanupACLEnt(cm_aclent_t * aclp)
 
 /*
  * Get an acl cache entry for a particular user and file, or return that it doesn't exist.
- * Called with the scp locked.
+ * Called with the scp write locked.
  */
 long cm_FindACLCache(cm_scache_t *scp, cm_user_t *userp, afs_uint32 *rightsp)
 {
@@ -74,6 +74,7 @@ long cm_FindACLCache(cm_scache_t *scp, cm_user_t *userp, afs_uint32 *rightsp)
     long retval = -1;
     time_t now = time(NULL);
 
+    lock_AssertWrite(&scp->rw);
     lock_ObtainWrite(&cm_aclLock);
     *rightsp = 0;   /* get a new acl from server if we don't find a
                      * current entry