Ad

CVE-2026-99416

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

В ядре Linux была устранена следующая уязвимость: ovl: read the nlink xattr of every indexed non-dir With nfs_export=on, данные, записанные через обработчик файла в более низкий файл, то есть файл, существующий только в нижнем слое наложения, может быть потерян на следующем монтировании. Поиск файла по имени затем возвращает -EIO. Кроме того, файл с одним именем сообщает st_nlink 2 после того, как он был скопирован в верхний слой.

После того, как такой файл удален, его файловая ручка все еще может открыть его до следующего монтирования. Перед тем, как нижний файл будет изменен в первый раз, overlayfs копирует его на записываемый верхний слой. Это называется копирование вверх.

Каталог индекса - $workdir/index, где $workdir - это каталог, заданный параметром workdir. Каждая запись названа в честь файловой ручки более низкого inode, так что оверлейные файлы могут попасть от ручки к скопированному inode. С помощью nfs_export=on, копирование вверх индексирует каждый не-каталог: он копирует файл в запись в каталоге индекса, а затем жесткие ссылки, которые входят в верхний каталог.

Индексная запись является дополнительной ссылкой на верхний inode, поэтому overlayfs хранит количество ссылок, которые пользователи должны видеть в overlay.nlink xattr. Файл также может быть открыт ручкой, либо клиентом NFS, либо процессом с CAP_DAC_READ_SEARCH, вызывающим open_by_handle_at(). Если файл не находится в dcache, его наложение dentry отключено, т.е. у него еще нет родителя.

Копировать вверх затем создает запись индекса, но нет жесткой ссылки в верхнем каталоге. Запись индекса имеет i_nlink 1 и содержит единственную копию данных, записанных в файл. ovl_get_nlink() считывает сохраненное количество. Его абонент передает по умолчанию, который функция возвращает, если нет сохраненного количества.

Если нижний inode имеет i_nlink 1, функция возвращает значение по умолчанию без чтения xattr. Это было верно, пока индексировались только более низкие файлы с несколькими ссылками. На следующем монтировании ovl_verify_index() ищет сирот, то есть индексирует записи файлов, фамилия которых была удалена.

Для индексной записи с i_nlink 1 она передает по умолчанию 0 в ovl_get_nlink () и рассматривает результат 0 как сироту. Здесь нижний inode также имеет i_nlink 1, так что результат по умолчанию. ovl_indexdir_cleanup() затем заменяет запись белым цветом, который в индексе помечает файл как удаленный. Письменные данные теряются.

Поиск по имени затем возвращает -EIO, потому что отсечение в качестве индексной записи более низкого файла, который все еще существует, является плохим индексом. ovl_get_inode() получает неправильный подсчет таким же образом. Его по умолчанию является i_nlink верхнего inode, который включает в себя запись индекса, поэтому скопированный файл с одним именем сообщает st_nlink. Когда это имя удалено, количество падает до 1, а не до 0. ovl_nlink_end() заменяет запись индекса белым только при счете 0, поэтому запись остается, и ручка удаленного файла по-прежнему открывает его.

Воспроизводится путем записи через open_by_handle_at() в некэшированный нижний файл с одной ссылкой. После перемонтажа данные были потеряны, и имя вернулось EIO. Исправьте это, добавив аргумент в ovl_get_nlink(), который говорит, нашел ли звонящий запись индекса, и пропустив xattr, только если звонящий не нашел.

Известные пробелы: - Элемент индекса, который ядро без этого патча оставило для удаленного файла, теперь остается, и обработчик этого файла продолжает работать. Запись имеет i_nlink 1 и сохраненный счет 1, как и запись файла, который был записан только ручкой. Без этой патч, следующий mount относился к нему как к сироте.

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

In the Linux kernel, the following vulnerability has been resolved: ovl: read the nlink xattr of every indexed non-dir With nfs_export=on, data written through a file handle to a lower file, i.e. a file that exists only in a lower layer of the overlay, can be lost on the next mount. A lookup of the file by name then returns -EIO. Also, a file with one name reports st_nlink 2 once it has been copied to the upper layer. After such a file is removed, its file handle can still open it until the next mount. Before a lower file is changed for the first time, overlayfs copies it to the writable upper layer. This is called copy up. The index directory is $workdir/index, where $workdir is the directory given by the workdir= option. Each entry is named after the file handle of a lower inode, so that overlayfs can get from the handle to the copied up inode. With nfs_export=on, copy up indexes every non-directory: it copies the file to an entry in the index directory and then hard links that entry into the upper directory. The index entry is an extra link to the upper inode, so overlayfs stores the link count that users should see in the overlay.nlink xattr. A file can also be opened by handle, either by an NFS client or by a process with CAP_DAC_READ_SEARCH calling open_by_handle_at(). If the file is not in the dcache, its overlay dentry is disconnected, i.e. it has no parent yet. Copy up then creates the index entry but no hard link in the upper directory. The index entry has i_nlink 1 and holds the only copy of the data written to the file. ovl_get_nlink() reads the stored count. Its caller passes a default, which the function returns if there is no stored count. If the lower inode has i_nlink 1, the function returns the default without reading the xattr. That was correct as long as only lower files with multiple links were indexed. On the next mount, ovl_verify_index() looks for orphans, i.e. index entries of files whose last name was removed. For an index entry with i_nlink 1, it passes a default of 0 to ovl_get_nlink() and treats a result of 0 as an orphan. Here the lower inode also has i_nlink 1, so the result is the default. ovl_indexdir_cleanup() then replaces the entry with a whiteout, which in the index marks a file as deleted. The written data is lost. A lookup by name then returns -EIO, because a whiteout as the index entry of a lower file that still exists is a bad index. ovl_get_inode() gets the wrong count the same way. Its default is the i_nlink of the upper inode, which includes the index entry, so a copied up file with one name reports st_nlink 2. When that name is removed, the count drops to 1 rather than 0. ovl_nlink_end() replaces the index entry with a whiteout only at a count of 0, so the entry stays, and the handle of the removed file still opens it. Reproduced by writing through open_by_handle_at() to an uncached lower file with one link. After a remount the data was lost, and the name returned EIO. Fix this by adding an argument to ovl_get_nlink() that says whether the caller found an index entry, and by skipping the xattr only if the caller found none. Known gaps: - An index entry that a kernel without this patch left behind for a removed file now stays, and the handle of that file keeps working. The entry has i_nlink 1 and a stored count of 1, just like the entry of a file that was only written by handle. Without this patch, the next mount treated it as an orphan.