I have a question regarding data manipulation in race conditions.
For example in my filter driver I can see that I have a lot of DispatchCreate calls, also a lot of DispatchRead calls.
I want to know if these calls can cause race conditions, if I process them shyncronously (completion routine, etc. . .)
By race conditions I mean, if my dipatch read routine “comunicates” with a driver entry created system thread (because I want to access pageable data with the thread that is running at PASSIVE_LEVEL, and my dispatch read which may run at DISPATCH_LEVEL I can’t. In my dispatch read I let all IRP_PAGING_IO and IRP_SYNCHRONOUS_PAGING_IO pass through), with the help of a globally decalred event and a locked nonpaged Mdl, can I have the risk that when, in a read request, that I want to pass some data to the thread and wait for it on the event for the thread to finish, another request is made in this time, and changes the event state, or tries to access the the mdl and modify it, and my “first” request get’s junk data because of other concurent request.
Is this possible or the IO manager waits for the Irp’s to be completed before calling the dispatch routines, for the next Irp.
I tried to use FAST_MUTEX for this issue but eventualy the driver slowly freezez the computer. What can happen if I acquire a fast mutex, get the control of the fast_mutex, and in the time I try to process data more then 2 threads try to acquire the mutex, this means they go in the wait state, but which of the threads will gain control of the mutex first alfter I release it ?
How do you handle such problems generally in a filter driver ?
thank you.