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.
As discovered by https://ci.appveyor.com/project/Maxhy/dokany/builds/48885006/job/9yspbde528vgbq3m , nothing prevents a
PMOUNT_ENTRY
retrieved fromFindMountEntry
orFindMountEntryByName
to become unsafe due to a removal during a concurrent parallel unmountDokanDeleteDeviceObject
.PMOUNT_ENTRY
should have a lock that is acquired while holding thedokanGlobal->Resource
lock (already used byFindMountEntry
) and that new lock should be released whenPMOUNT_ENTRY
is not longer required.dokanGlobal->Resource
lock can be released after lockingPMOUNT_ENTRY
.RemoveMountEntry
will also need to hold this lock withdokanGlobal->Resource
and the new lock acquired.