dokan-dev / dokany

User mode file system library for windows with FUSE Wrapper
http://dokan-dev.github.io
5.15k stars 657 forks source link

Kernel - DokanGlobal->MountPointList items access isn't safe #1191

Closed Liryna closed 6 months ago

Liryna commented 6 months ago

As discovered by https://ci.appveyor.com/project/Maxhy/dokany/builds/48885006/job/9yspbde528vgbq3m , nothing prevents a PMOUNT_ENTRY retrieved from FindMountEntry or FindMountEntryByName to become unsafe due to a removal during a concurrent parallel unmount DokanDeleteDeviceObject.

PMOUNT_ENTRY should have a lock that is acquired while holding the dokanGlobal->Resource lock (already used by FindMountEntry ) and that new lock should be released when PMOUNT_ENTRY is not longer required. dokanGlobal->Resource lock can be released after locking PMOUNT_ENTRY. RemoveMountEntry will also need to hold this lock with dokanGlobal->Resource and the new lock acquired.