Ad

CVE-2025-40007

NONE EPSS 0.22%
Обновлено 20 октября 2026
Ceph
Параметр Значение
Поставщик Ceph
Публичный эксплойт Нет

В ядре Linux устранена следующая уязвимость: netfs: исправлена утечка ссылок Commit 20d72b00ca81 («netfs: исправить рабочий элемент запроса, чтобы он не требуется ссылка") изменил netfs_alloc_request() для инициализации счетчик ссылок равен 2 вместо 1. Причина заключалась в том, что «работа» запроса выпустит вторую ссылку после завершения (через netfs_{read,write}_collection_worker()). Это работает большую часть время, если все пойдет хорошо.

Однако эта дополнительная ссылка теряется, если запрос выпущен. до отправки операции ввода-вывода: только путь к коду ошибки уменьшает счетчик ссылок один раз, и рабочий элемент никогда не будет поставлен в очередь, потому что завершения никогда не будет. Сегодня это вызвало сбои в работе всего нашего кластера серверов, поскольку задачи были заблокированы в netfs_wait_for_outstanding_io(), что привело к взаимоблокировки в Ceph (еще одна ошибка, которую я скоро рассмотрю в другом патч). Это было вызвано вызовом netfs_pgpriv2_begin_copy_to_cache(). что не удалось сделать в fscache_begin_write_operation().

Утечка netfs_io_request так и не был завершен, остался `netfs_inode.io_count` с положительным значением навсегда. Все это сверххрупкий код. Выяснение того, какие пути кода будут приводят к окончательному завершению, а какие нет, трудно увидеть: - Некоторые функции, такие как netfs_create_write_req(), выделяют запрос, но никогда не будет отправлять какие-либо операции ввода-вывода. - netfs_unbuffered_read_iter_locked() вызывает netfs_unbuffered_read() а затем netfs_put_request(); однако netfs_unbuffered_read() может также происходит сбой раньше, чем перед отправкой запроса ввода-вывода, поэтому другой Туда необходимо добавить вызов netfs_put_request().

Эмпирическое правило заключается в том, что функции, возвращающие `netfs_io_request`, не отправлять ввод-вывод, и все вызывающие их объекты должны быть проверены. На мой взгляд, весь код netfs нуждается в капитальном ремонте, чтобы на него можно было ссылаться. счет легче понять, он менее хрупкий и неясный. Но чтобы исправить эту ошибку здесь и сейчас и создайте патч, подходящий для стабильный бэкпорт, я попробовал минимальный подход, который быстро освобождает запросить объект при раннем сбое.

Я решил не добавлять каждый раз второй netfs_put_request(). потому что это приведет к дублированию кода, которое скроет код дальше. Вместо этого я добавил функцию netfs_put_failed_request(). который освобождает такой неудачный запрос синхронно, при условии, что что счетчик ссылок равен ровно 2 (как изначально установлено netfs_alloc_request() и никогда не трогался), проверено ПРЕДУПРЕЖДЕНИЕ_ON_ONCE(). Затем он деинициализирует объект запроса (без проходя косвенное направление «cleanup_work») и освобождает выделение (с защитой RCU для защиты от одновременного доступа netfs_requests_seq_start()).

Все пути кода, которые терпят неудачу раньше, были изменены на вызов netfs_put_failed_request() вместо netfs_put_request(). Кроме того, я добавил вызов netfs_put_request() в netfs_unbuffered_read(), как описано выше, поскольку Подход netfs_put_failed_request() здесь не работает.

Показать оригинальное описание (EN)

In the Linux kernel, the following vulnerability has been resolved: netfs: fix reference leak Commit 20d72b00ca81 ("netfs: Fix the request's work item to not require a ref") modified netfs_alloc_request() to initialize the reference counter to 2 instead of 1. The rationale was that the requet's "work" would release the second reference after completion (via netfs_{read,write}_collection_worker()). That works most of the time if all goes well. However, it leaks this additional reference if the request is released before the I/O operation has been submitted: the error code path only decrements the reference counter once and the work item will never be queued because there will never be a completion. This has caused outages of our whole server cluster today because tasks were blocked in netfs_wait_for_outstanding_io(), leading to deadlocks in Ceph (another bug that I will address soon in another patch). This was caused by a netfs_pgpriv2_begin_copy_to_cache() call which failed in fscache_begin_write_operation(). The leaked netfs_io_request was never completed, leaving `netfs_inode.io_count` with a positive value forever. All of this is super-fragile code. Finding out which code paths will lead to an eventual completion and which do not is hard to see: - Some functions like netfs_create_write_req() allocate a request, but will never submit any I/O. - netfs_unbuffered_read_iter_locked() calls netfs_unbuffered_read() and then netfs_put_request(); however, netfs_unbuffered_read() can also fail early before submitting the I/O request, therefore another netfs_put_request() call must be added there. A rule of thumb is that functions that return a `netfs_io_request` do not submit I/O, and all of their callers must be checked. For my taste, the whole netfs code needs an overhaul to make reference counting easier to understand and less fragile & obscure. But to fix this bug here and now and produce a patch that is adequate for a stable backport, I tried a minimal approach that quickly frees the request object upon early failure. I decided against adding a second netfs_put_request() each time because that would cause code duplication which obscures the code further. Instead, I added the function netfs_put_failed_request() which frees such a failed request synchronously under the assumption that the reference count is exactly 2 (as initially set by netfs_alloc_request() and never touched), verified by a WARN_ON_ONCE(). It then deinitializes the request object (without going through the "cleanup_work" indirection) and frees the allocation (with RCU protection to protect against concurrent access by netfs_requests_seq_start()). All code paths that fail early have been changed to call netfs_put_failed_request() instead of netfs_put_request(). Additionally, I have added a netfs_put_request() call to netfs_unbuffered_read() as explained above because the netfs_put_failed_request() approach does not work there.