]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Windows: Detect if AFSCache is memory mapped to a new address
authorJeffrey Altman <jaltman@your-file-system.com>
Mon, 7 Jun 2010 22:18:39 +0000 (18:18 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Wed, 9 Jun 2010 14:36:21 +0000 (07:36 -0700)
The Windows AFSCache paging file contains pointer addresses
that are only valid if the file is memory mapped at a specific
memory address.  If the file is mapped at a new address, the
pointer values will be invalid and the service will crash with
an invalid memory access.

Check for address consistency and force the cache to be rebuilt
if the consistency is lost.

LICENSE MIT

Change-Id: Ie7fb64659f808f09279445f47c2f1385be0a53f0
Reviewed-on: http://gerrit.openafs.org/2095
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
src/WINNT/afsd/cm_memmap.c

index bf9767cb6ffc7dc8baaa0c96a044d4a8e402b3a1..3b946129167034a58b28395c3ff94bd12fdee4ab 100644 (file)
@@ -817,7 +817,8 @@ cm_InitMappedMemory(DWORD virtualCache, char * cachePath, DWORD stats, DWORD max
         afsi_log("Reusing existing AFS Cache data:");
         cm_data = *config_data_p;      
 
-       afsi_log("  Base Address   = %p",baseAddress);
+       afsi_log("  Map Address    = %p", baseAddress);
+       afsi_log("  baseAddress    = %p", config_data_p->baseAddress);
        afsi_log("  stats          = %u", config_data_p->stats);
        afsi_log("  chunkSize      = %u", config_data_p->chunkSize);
        afsi_log("  blockSize      = %u", config_data_p->blockSize);
@@ -833,9 +834,18 @@ cm_InitMappedMemory(DWORD virtualCache, char * cachePath, DWORD stats, DWORD max
        afsi_log("  currentSCaches = %u", config_data_p->currentSCaches);
        afsi_log("  maxSCaches     = %u", config_data_p->maxSCaches);
 
-        // perform validation of persisted data structures
-        // if there is a failure, start from scratch
-        if (cm_ValidateCache && !cm_IsCacheValid()) {
+        /*
+         * perform validation of persisted data structures
+         * if there is a failure, start from scratch
+         *
+         * if the baseAddress changed then the embedded pointers
+         * within the data structures are no longer valid.
+         * in theory we could walk the tree and adjust the pointer
+         * values based on the offet but that has not been
+         * implemented.
+         */
+        if (baseAddress != cm_data.baseAddress ||
+            cm_ValidateCache && !cm_IsCacheValid()) {
             newFile = 1;
         }
     }