]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Apply STABLE14-linux-mmap-antirecursion-fix-20090512
authorRuss Allbery <rra@debian.org>
Tue, 26 May 2009 23:47:24 +0000 (16:47 -0700)
committerRuss Allbery <rra@debian.org>
Tue, 26 May 2009 23:47:24 +0000 (16:47 -0700)
* Apply upstream CVS deltas:
  - STABLE14-linux-mmap-antirecursion-fix-20090512: improvements in
    flag setting and locking around recursive mmap protection.

debian/changelog
src/afs/LINUX/osi_vm.c
src/afs/LINUX/osi_vnodeops.c

index 0428a8f1ef29e1e524698067156dda4211bceba2..de47b90b99b964410c0c66242547f29e6195597c 100644 (file)
@@ -5,6 +5,8 @@ openafs (1.4.10+dfsg1-2) UNRELEASED; urgency=low
       when the real and effective credentials of a process differ to avoid
       running afoul of checks in newer Linux kernels that cause oops.
       (Closes: #528785)
+    - STABLE14-linux-mmap-antirecursion-fix-20090512: improvements in
+      flag setting and locking around recursive mmap protection.
   * Provide an openafs-modules-dkms package that uses DKMS to dynamically
     build kernel modules for the local kernel and document this option in
     README.modules.  This is an alternative to installing
index 4917f977aeae112928e178d835d7657085a77c25..fb8f18134c393fb4c060e63e53971b1811f2ee57 100644 (file)
@@ -11,7 +11,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/LINUX/osi_vm.c,v 1.16.2.5 2009/03/27 15:45:49 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/LINUX/osi_vm.c,v 1.16.2.6 2009/05/12 17:56:50 shadow Exp $");
 
 #include "afs/sysincludes.h"   /* Standard vendor system headers */
 #include "afsincludes.h"       /* Afs-based standard headers */
@@ -102,9 +102,7 @@ osi_VM_StoreAllSegments(struct vcache *avc)
 {
     struct inode *ip = AFSTOV(avc);
 
-    if (!avc->states & CPageWrite)
-       avc->states |= CPageWrite;
-    else 
+    if (avc->states & CPageWrite)
        return; /* someone already writing */
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,5)
@@ -120,7 +118,6 @@ osi_VM_StoreAllSegments(struct vcache *avc)
     AFS_GLOCK();
     ObtainWriteLock(&avc->lock, 121);
 #endif
-    avc->states &= ~CPageWrite;
 }
 
 /* Purge VM for a file when its callback is revoked.
index bd3661acf37e97b804458d4de9bb4399f873d496..32a02e8f6d4f57f2c8c6eda22d59befb7fc52098 100644 (file)
@@ -1567,9 +1567,9 @@ afs_linux_writepage_sync(struct inode *ip, struct page *pp,
               ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, page_count(pp),
               ICL_TYPE_INT32, 99999);
 
-    ObtainReadLock(&vcp->lock);
+    ObtainWriteLock(&vcp->lock, 532);
     if (vcp->states & CPageWrite) {
-       ReleaseReadLock(&vcp->lock);
+       ReleaseWriteLock(&vcp->lock);
        AFS_GUNLOCK();
        unlock_kernel();
        crfree(credp);
@@ -1585,7 +1585,8 @@ afs_linux_writepage_sync(struct inode *ip, struct page *pp,
        return(0); 
 #endif
     }
-    ReleaseReadLock(&vcp->lock);
+    vcp->states |= CPageWrite;
+    ReleaseWriteLock(&vcp->lock);
 
     setup_uio(&tuio, &iovec, buffer, base, count, UIO_WRITE, AFS_UIOSYS);
 
@@ -1594,16 +1595,18 @@ afs_linux_writepage_sync(struct inode *ip, struct page *pp,
     i_size_write(ip, vcp->m.Length);
     ip->i_blocks = ((vcp->m.Length + 1023) >> 10) << 1;
 
+    ObtainWriteLock(&vcp->lock, 533);
     if (!code) {
        struct vrequest treq;
 
-       ObtainWriteLock(&vcp->lock, 533);
        if (!afs_InitReq(&treq, credp))
            code = afs_DoPartialWrite(vcp, &treq);
-       ReleaseWriteLock(&vcp->lock);
     }
     code = code ? -code : count - tuio.uio_resid;
 
+    vcp->states &= ~CPageWrite;
+    ReleaseWriteLock(&vcp->lock);
+
     afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp,
               ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, page_count(pp),
               ICL_TYPE_INT32, code);
@@ -1658,7 +1661,12 @@ afs_linux_writepage(struct page *pp)
   do_it:
     status = afs_linux_writepage_sync(inode, pp, 0, offset);
     SetPageUptodate(pp);
-    UnlockPage(pp);
+#if defined(WRITEPAGE_ACTIVATE)
+    if ( status != WRITEPAGE_ACTIVATE )
+#else
+    if ( status != AOP_WRITEPAGE_ACTIVATE )
+#endif
+       UnlockPage(pp);
     if (status == offset)
        return 0;
     else