In the Linux kernel, the following vulnerability has been resolved:
drivers: tty: serial: Fix deadlock in sa1100settermios()
There is a deadlock in sa1100settermios(), which is shown below:
(Thread 1) | (Thread 2) | sa1100enablems() sa1100settermios() | modtimer() spinlockirqsave() //(1) | (wait a time) ... | sa1100timeout() deltimersync() | spinlockirqsave() //(2) (wait timer to stop) | ...
We hold sport->port.lock in position (1) of thread 1 and use deltimersync() to wait timer to stop, but timer handler also need sport->port.lock in position (2) of thread 2. As a result, sa1100settermios() will block forever.
This patch moves deltimersync() before spinlockirqsave() in order to prevent the deadlock.