mirror of
https://github.com/winfsp/winfsp.git
synced 2025-07-03 09:22:57 -05:00
sys: FspFsvolReadNonCached: trim ReadLength
During CreateProcess/CreateSection Windows locks the image file (using AcquireFileForNtCreateSection), gets the image file size and then reads the image file. Unfortunately if the file system (erroneously) reads past the file size, Windows can bugcheck. This allows a faulty or malicious file system to crash Windows. This commit adds a check in WinFsp to mitigate this problem.
This commit is contained in:
@ -78,6 +78,7 @@ VOID FspAcquireFileForNtCreateSection(
|
||||
{
|
||||
/* Callers:
|
||||
* CcWriteBehind
|
||||
* MmCreateSection and friends
|
||||
*/
|
||||
|
||||
FSP_ENTER_VOID(PAGED_CODE());
|
||||
@ -85,6 +86,8 @@ VOID FspAcquireFileForNtCreateSection(
|
||||
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
||||
|
||||
FspFileNodeAcquireExclusive(FileNode, Full);
|
||||
ASSERT(FALSE == FileNode->Tls.CreateSection);
|
||||
FileNode->Tls.CreateSection = TRUE;
|
||||
|
||||
FSP_LEAVE_VOID("FileObject=%p", FileObject);
|
||||
}
|
||||
@ -94,12 +97,14 @@ VOID FspReleaseFileForNtCreateSection(
|
||||
{
|
||||
/* Callers:
|
||||
* CcWriteBehind
|
||||
* MmCreateSection and friends
|
||||
*/
|
||||
|
||||
FSP_ENTER_VOID(PAGED_CODE());
|
||||
|
||||
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
||||
|
||||
FileNode->Tls.CreateSection = FALSE;
|
||||
FspFileNodeRelease(FileNode, Full);
|
||||
|
||||
FSP_LEAVE_VOID("FileObject=%p", FileObject);
|
||||
|
Reference in New Issue
Block a user