In the Linux kernel, the following vulnerability has been resolved:
drivers: staging: rtl8192e: Fix deadlock in rtllibbeaconsstop()
There is a deadlock in rtllibbeaconsstop(), which is shown below:
(Thread 1) | (Thread 2) | rtllibsendbeacon() rtllibbeaconsstop() | modtimer() spinlockirqsave() //(1) | (wait a time) ... | rtllibsendbeaconcb() deltimersync() | spinlockirqsave() //(2) (wait timer to stop) | ...
We hold ieee->beaconlock in position (1) of thread 1 and use deltimersync() to wait timer to stop, but timer handler also need ieee->beaconlock in position (2) of thread 2. As a result, rtllibbeaconsstop() will block forever.
This patch extracts deltimersync() from the protection of spinlockirqsave(), which could let timer handler to obtain the needed lock.