[NTOS:CM] Ignore syncing/flushing requests after registry shutdown

When shutting down the registry of the system we don't want that the registry in question gets poked again, such as flushing the hives or syncing the hives and respective logs for example. The reasoning behind this is very simple, during a complete shutdown the system does final check-ups and stuff until the computer
shuts down.

Any writing operations done to the registry can lead to erratic behaviors. CmShutdownSystem call already invokes a final flushing of all the hives on the backing storage which is more than enough to ensure consistency of the last session configuration. So after that final flushing, mark HvShutdownComplete as TRUE indicating
that any eventual flushing or syncying (in the case where HvSyncHive gets called) request is outright ignored.
This commit is contained in:
George Bișoc 2022-10-26 18:51:09 +02:00
parent 99fab7b905
commit 0d776beac9
No known key found for this signature in database
GPG key ID: 688C4FBE25D7DEF6
2 changed files with 10 additions and 1 deletions

View file

@ -21,7 +21,6 @@ LIST_ENTRY CmpSelfHealQueueListHead;
KEVENT CmpLoadWorkerEvent;
LONG CmpLoadWorkerIncrement;
PEPROCESS CmpSystemProcess;
BOOLEAN HvShutdownComplete;
PVOID CmpRegistryLockCallerCaller, CmpRegistryLockCaller;
BOOLEAN CmpFlushOnLockRelease;
BOOLEAN CmpSpecialBootCondition;
@ -30,6 +29,7 @@ BOOLEAN CmpWasSetupBoot;
BOOLEAN CmpProfileLoaded;
BOOLEAN CmpNoVolatileCreates;
ULONG CmpTraceLevel = 0;
BOOLEAN HvShutdownComplete = FALSE;
extern LONG CmpFlushStarveWriters;
extern BOOLEAN CmFirstTime;
@ -2049,6 +2049,14 @@ CmShutdownSystem(VOID)
ListEntry = ListEntry->Flink;
}
/*
* As we flushed all the hives on the disk,
* tell the system we do not want any further
* registry flushing or syncing at this point
* since we are shutting down the registry anyway.
*/
HvShutdownComplete = TRUE;
CmpUnlockRegistry();
}

View file

@ -1473,6 +1473,7 @@ extern BOOLEAN CmpProfileLoaded;
extern PCMHIVE CmiVolatileHive;
extern LIST_ENTRY CmiKeyObjectListHead;
extern BOOLEAN CmpHoldLazyFlush;
extern BOOLEAN HvShutdownComplete;
//
// Inlined functions