mirror of
https://github.com/reactos/reactos.git
synced 2025-07-29 10:12:00 +00:00
- Reference/dereference the file object when working with it in the context of MPW thread. This prevents massive file operations (like copying) to crash ReactOS with writing to a freed memory exception.
svn path=/trunk/; revision=30564
This commit is contained in:
parent
34d621bb58
commit
03be8c2b8f
1 changed files with 10 additions and 1 deletions
|
@ -237,10 +237,16 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count)
|
|||
current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT,
|
||||
DirtySegmentListEntry);
|
||||
current_entry = current_entry->Flink;
|
||||
|
||||
|
||||
/* This Ros-specific function needs FileObject to be referenced,
|
||||
ohterwise it may be deleted while this function still works
|
||||
with it */
|
||||
ObReferenceObject(current->Bcb->FileObject);
|
||||
|
||||
Locked = ExTryToAcquireResourceExclusiveLite(((FSRTL_COMMON_FCB_HEADER*)(current->Bcb->FileObject->FsContext))->Resource);
|
||||
if (!Locked)
|
||||
{
|
||||
ObDereferenceObject(current->Bcb->FileObject);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -248,6 +254,7 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count)
|
|||
if (!Locked)
|
||||
{
|
||||
ExReleaseResourceLite(((FSRTL_COMMON_FCB_HEADER*)(current->Bcb->FileObject->FsContext))->Resource);
|
||||
ObDereferenceObject(current->Bcb->FileObject);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -256,6 +263,7 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count)
|
|||
{
|
||||
ExReleasePushLock(¤t->Lock);
|
||||
ExReleaseResourceLite(((FSRTL_COMMON_FCB_HEADER*)(current->Bcb->FileObject->FsContext))->Resource);
|
||||
ObDereferenceObject(current->Bcb->FileObject);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -267,6 +275,7 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count)
|
|||
|
||||
ExReleasePushLock(¤t->Lock);
|
||||
ExReleaseResourceLite(((FSRTL_COMMON_FCB_HEADER*)(current->Bcb->FileObject->FsContext))->Resource);
|
||||
ObDereferenceObject(current->Bcb->FileObject);
|
||||
|
||||
if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue