X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=drivers%2Ffilesystems%2Fbtrfs%2Fbtrfs.c;h=c4960cd4215ae813029c9e32a595c474b130d66a;hp=27a1572db8c6a7b7effedbafea413fc9eb9cc1ed;hb=c13ccc92f66d9fd537ffdd4c0324af5b9c2723e1;hpb=80e11516b12b19530b56be7539ecc6af2039ed7b diff --git a/drivers/filesystems/btrfs/btrfs.c b/drivers/filesystems/btrfs/btrfs.c index 27a1572db8c..c4960cd4215 100644 --- a/drivers/filesystems/btrfs/btrfs.c +++ b/drivers/filesystems/btrfs/btrfs.c @@ -4453,7 +4453,21 @@ static NTSTATUS mount_vol(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp) { goto exit; } + /* HACK: stream file object seems to get deleted at some point + * leading to use after free when installing ReactOS on + * BtrFS. + * Workaround: leak a handle to the fileobject + * XXX: Could be improved by storing it somewhere and releasing it + * on dismount. Or even by referencing again the file object. + */ +#ifndef __REACTOS__ Vcb->root_file = IoCreateStreamFileObject(NULL, DeviceToMount); +#else + { + HANDLE Dummy; + Vcb->root_file = IoCreateStreamFileObjectEx(NULL, DeviceToMount, &Dummy); + } +#endif Vcb->root_file->FsContext = root_fcb; Vcb->root_file->SectionObjectPointer = &root_fcb->nonpaged->segment_object; Vcb->root_file->Vpb = DeviceObject->Vpb;