From 30b836bf3f48055deceb5e1a5100921d40cad073 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 21 May 2018 10:28:44 +0200 Subject: [PATCH] [FASTFAT] When extending a file, also lock the DirResource. This avoids race conditions under high IOs and thus corruption on the FS, or assertions failures in the kernel. Easily triggered by building ReactOS on ReactOS ;-). --- drivers/filesystems/fastfat/rw.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/filesystems/fastfat/rw.c b/drivers/filesystems/fastfat/rw.c index 76ffff933c5..ad65628876a 100644 --- a/drivers/filesystems/fastfat/rw.c +++ b/drivers/filesystems/fastfat/rw.c @@ -1064,9 +1064,18 @@ VfatWrite( ByteOffset.u.LowPart + Length > Fcb->RFCB.FileSize.u.LowPart) { LARGE_INTEGER AllocationSize; + + if (!ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource, CanWait)) + { + goto ByeBye; + } + AllocationSize.QuadPart = ByteOffset.u.LowPart + Length; Status = VfatSetAllocationSizeInformation(IrpContext->FileObject, Fcb, IrpContext->DeviceExt, &AllocationSize); + + ExReleaseResourceLite(&IrpContext->DeviceExt->DirResource); + if (!NT_SUCCESS (Status)) { goto ByeBye;