В ядре Linux устранена следующая уязвимость: ovl: look up the index by the decoded origin Файл, открытый файловой обработкой на оверле с помощью nfs_export=on, может показывать устаревшие нижние данные файла, который был скопирован до верхнего слоя. В то время как файл, открытый таким образом, остается в кэше inode, поиск скопированного файла по пути не удается с ESTALE для всех пользователей. Открытый также может преуспеть для файла, который был удален, где он должен потерпеть неудачу с ESTALE.
Это происходит с ручкой, которая изменила один байт. Обработчик происходит из клиента NFS или из процесса, который вызывает open_by_handle_at () с CAP_DAC_READ_SEARCH в начальном пространстве имен пользователей. Когда файл в нижнем слое собирается быть измененным, наложения сначала копируют его в верхний слой (копируют вверх).
С nfs_export=on каждая копия также создает запись в каталоге индекса, каталог, который оверлейфы сохраняют для себя в верхней файловой системе. Ручка файла наложения, которая исходит из нижнего слоя, обматывает ручку его нижнего inode. Overlayfs называет эту нижнюю иноду происхождением.
Ручка оверлея остается в силе после копирования. Чтобы декодировать такую ручку, ovl_lower_fh_to_d() сначала декодирует обернутую ручку к источнику. Если для исходного файла не кэшируется ни один оверлейный inode, он выглядит в каталоге индекса: - Запись индекса там ведет к верхнему файлу. - Отбеливание, маркер, который оверлей использует для удаленного файла, означает, что файл оверлей был удален.
Имя записи индекса - это ручка, которая копируется в исходную строку, как шестнадцатеричная строка. ovl_lower_fh_to_d() строит имя для этого поиска из байтов, которые абонент передал. Но ручки с разными байтами могут декодироваться в один и тот же inode: - Overlayfs игнорирует некоторые биты флага ручки. - Нижняя файловая система может принимать другой тип fid, дополнительные байты или поколение 0 для любого поколения. Такая ручка декодирует исходный код, но пропускает запись индекса или отсечение.
Таким образом, декодирование возвращает оверлейный инод, который имеет только нижний файл. В то время как этот inode кэшируется, поиск пути скопированного файла не удается с ESTALE, так как верхний файл, который находит поиск, не соответствует кэшированному inode, у которого его нет. Воспроизводится на tmpfs и на ext4 с open_by_handle_at(), после копирования и цикла монтирования.
Ручка, в которой был изменен один бит флага, тип fid, длина или поколение, читает старые нижние данные, а поиск пути возвращает ESTALE. Исправьте это, перекодировав декодированный источник и построив имя индекса с этой ручки.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: ovl: look up the index by the decoded origin A file opened by file handle on an overlay with nfs_export=on can show the stale lower data of a file that was copied up to the upper layer. While the file opened this way stays in the inode cache, a lookup of the copied up file by path fails with ESTALE for all users. The open can also succeed for a file that was removed, where it has to fail with ESTALE. This happens with a handle that has one byte changed. The handle comes from an NFS client, or from a process that calls open_by_handle_at() with CAP_DAC_READ_SEARCH in the initial user namespace. When a file in a lower layer is about to be modified, overlayfs first copies it to the upper layer (copy up). With nfs_export=on, each copy up also creates an entry in the index directory, a directory that overlayfs keeps for itself on the upper filesystem. The handle of an overlay file that comes from a lower layer wraps the handle of its lower inode. Overlayfs calls this lower inode the origin. The overlay handle stays valid after a copy up. To decode such a handle, ovl_lower_fh_to_d() first decodes the wrapped handle to the origin. If no overlay inode is cached for the origin, it looks in the index directory: - An index entry there leads to the upper file. - A whiteout, the marker that overlayfs uses for a removed file, means that the overlay file was removed. The name of an index entry is the handle that copy up encoded for the origin, as a hex string. ovl_lower_fh_to_d() builds the name for this lookup from the bytes that the caller passed in. But handles with different bytes can decode to the same inode: - Overlayfs ignores some flag bits of the handle. - A lower filesystem can accept a different fid type, extra bytes, or generation 0 for any generation. Such a handle decodes to the origin but misses the index entry or the whiteout. So the decode returns an overlay inode that has only the lower file. While that inode is cached, a path lookup of a copied up file fails with ESTALE, since the upper file that the lookup finds does not match the cached inode, which has none. Reproduced on tmpfs and on ext4 with open_by_handle_at(), after a copy up and a mount cycle. A handle in which one flag bit, the fid type, the length or the generation was changed read the old lower data, and path lookups returned ESTALE. Fix this by re-encoding the decoded origin and building the index name from that handle.