Skip to content

Commit 367cb1f

Browse files
HeisSpiterJoachimHenze
authored andcommitted
[0.4.9] cherry-pick [FASTFAT] Lock DirResource when modifying an entry on disk.
Likely not optimal, but fixes some races conditions where the directory is uninit in the middle of the write. (cherry picked from commit fc788cf)
1 parent 8b45da6 commit 367cb1f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/filesystems/fastfat/finfo.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,7 @@ VfatSetInformation(
15521552
PVFATFCB FCB;
15531553
NTSTATUS Status = STATUS_SUCCESS;
15541554
PVOID SystemBuffer;
1555+
BOOLEAN LockDir;
15551556

15561557
/* PRECONDITION */
15571558
ASSERT(IrpContext);
@@ -1593,7 +1594,14 @@ VfatSetInformation(
15931594
DPRINT("Can set file size\n");
15941595
}
15951596

1596-
if (FileInformationClass == FileRenameInformation)
1597+
LockDir = FALSE;
1598+
if (FileInformationClass == FileRenameInformation || FileInformationClass == FileAllocationInformation ||
1599+
FileInformationClass == FileEndOfFileInformation || FileInformationClass == FileBasicInformation)
1600+
{
1601+
LockDir = TRUE;
1602+
}
1603+
1604+
if (LockDir)
15971605
{
15981606
if (!ExAcquireResourceExclusiveLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource,
15991607
BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT)))
@@ -1607,7 +1615,7 @@ VfatSetInformation(
16071615
if (!ExAcquireResourceExclusiveLite(&FCB->MainResource,
16081616
BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT)))
16091617
{
1610-
if (FileInformationClass == FileRenameInformation)
1618+
if (LockDir)
16111619
{
16121620
ExReleaseResourceLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource);
16131621
}
@@ -1662,7 +1670,7 @@ VfatSetInformation(
16621670
ExReleaseResourceLite(&FCB->MainResource);
16631671
}
16641672

1665-
if (FileInformationClass == FileRenameInformation)
1673+
if (LockDir)
16661674
{
16671675
ExReleaseResourceLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource);
16681676
}

0 commit comments

Comments
 (0)