In the Linux kernel, the following vulnerability has been resolved:
driver core: fix deadlock in _deviceattach
In deviceattach function, The lock holding logic is as follows: ... _deviceattach devicelock(dev) // get lock dev asyncscheduledev(deviceattachasynchelper, dev); // func asyncschedulenode asyncschedulenodedomain(func) entry = kzalloc(sizeof(struct asyncentry), GFPATOMIC); /* when fail or work limit, sync to execute func, but _deviceattachasynchelper will get lock dev as well, which will lead to A-A deadlock. */ if (!entry || atomicread(&entrycount) > MAXWORK) { func; else queueworknode(node, systemunboundwq, &entry->work) deviceunlock(dev)
As shown above, when it is allowed to do async probes, because of out of memory or work limit, async work is not allowed, to do sync execute instead. it will lead to A-A deadlock because of _deviceattachasynchelper getting lock dev.
To fix the deadlock, move the asyncscheduledev outside devicelock, as we can see, in asyncschedulenodedomain, the parameter of queueworknode is systemunboundwq, so it can accept concurrent operations. which will also not change the code logic, and will not lead to deadlock.