https://git.reactos.org/?p=reactos.git;a=commitdiff;h=30b836bf3f48055deceb5…
commit 30b836bf3f48055deceb5e1a5100921d40cad073
Author:     Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Mon May 21 10:28:44 2018 +0200
Commit:     Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Mon May 21 10:30:14 2018 +0200
    [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 76ffff933c..ad65628876 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;