В ядре Linux была устранена следующая уязвимость: io_uring: don't flood a canceling task with task_work io_ring_exit_work() запрашивает каждую задачу, которая использовала кольцо для удаления узла tctx, у task_work, и повторяет это до тех пор, пока список не опустеет. io_tctx_exit_cb() не касается узла, пока задача находится в io_uring_cancel_generic(), что удаляет все узлы в его конец. Таким образом, рабочий элемент снова ставит в очередь обратный звонок, как только он завершился, ни за что. Это больше, чем пустая трата времени. task_work_run () возвращается только тогда, когда он находит список пустым.
Если кольца высвобождаются из-за того, что запросы других колец содержали последние ссылки на их файлы, до 64 рабочих элементов продолжают отправлять обратные вызовы к одной задаче, которая их выполняет. Он никогда не находит список пустым, никогда не возвращается к отмене, узлы остаются, и так продолжается: задача с 60 парами колец, которые опрашивают друг друга, пробежала 280000 обратных вызовов за 5 секунд, 20 секунд после exit_group (). Он заканчивается, когда все отправители опаздывают одновременно.
До тех пор задача сохраняет CPU и рабочие элементы занятыми. Выходящая задача не может быть убита тем временем. execve() отменяет запросы таким же образом, так что живая задача может застрять и там, на минуты. Если это занимает более пяти, рабочие элементы запускаются в WARN_ON_ONCE(time_after(jiffies, тайм-аут) io_ring_exit_work().
Никаких привилегий для этого не требуется. Если обратный звонок выполнил задачу в отмене, подождите немного, прежде чем он будет отправлен снова. Для этого никто не должен будить рабочий элемент: либо узел исчез к тому времени, либо настала очередь следующего раунда.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: io_uring: don't flood a cancelling task with task_work io_ring_exit_work() asks each task which has used the ring to remove its tctx node, by task_work, and repeats that until the list is empty. io_tctx_exit_cb() doesn't touch the node while the task is in io_uring_cancel_generic(), which removes all the nodes at its end. So the work item queues the callback again as soon as it has completed, for nothing. That is more than a waste of time. task_work_run() only returns when it finds the list empty. If the rings are released from inside the cancellation, because requests of other rings held the last references to their files, up to 64 work items keep sending callbacks to the one task which is running them. It never finds the list empty, never gets back to the cancellation, the nodes stay, and so it goes on: a task with 60 pairs of rings which poll each other ran 280000 callbacks in 5 seconds, 20 seconds after exit_group(). It ends when all the senders happen to be late at the same time. Until then the task keeps a CPU and the work items busy. An exiting task can't be killed meanwhile. execve() cancels the requests in the same way, so a live task can get stuck there as well, for minutes. If it takes more than five, the work items run into the WARN_ON_ONCE(time_after(jiffies, timeout)) of io_ring_exit_work(). No privilege is needed for any of this. If the callback has met a task in cancellation, wait a little before it is sent again. Nobody has to wake the work item up for that: either the node is gone by then, or it is the turn of the next round.