From 53304359a77442cf3dd3f9f2dc8543a1d16af668 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 7 Jun 2010 18:18:39 -0400 Subject: [PATCH] Windows: Detect if AFSCache is memory mapped to a new address 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 Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsd/cm_memmap.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/WINNT/afsd/cm_memmap.c b/src/WINNT/afsd/cm_memmap.c index bf9767cb6..3b9461291 100644 --- a/src/WINNT/afsd/cm_memmap.c +++ b/src/WINNT/afsd/cm_memmap.c @@ -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; } } -- 2.39.5