In the Linux kernel, the following vulnerability has been resolved:
tracing/timerlat: Drop interfacelock in stopkthread()
stopkthread() is the offline callback for "trace/osnoise:online", since commit 5bfbcd1ee57b ("tracing/timerlat: Add interfacelock around clearing of kthread in stop_kthread()"), the following ABBA deadlock scenario is introduced:
T1 | T2 [BP] | T3 [AP] osnoisehotplugworkfn() | workforcpufn() | cpuhpthreadfun() | _cpudown() | osnoisecpudie() mutexlock(&interfacelock) | | stopkthread() | cpuswritelock() | mutexlock(&interfacelock) cpusreadlock() | cpuhpkick_ap() |
As the interfacelock here in just for protecting the "kthread" field of the osnvar, use xchg() instead to fix this issue. Also use foreachonlinecpu() back in stoppercpukthreads() as it can take cpureadlock() again.