В ядре Linux была устранена следующая уязвимость: ovl: установить флаги перепроверки после того, как d_instantiate() stat() файла на оверлейном монтировании вызывает предупреждение ядра и терпит неудачу с ECHILD, если другая задача создает этот файл одновременно. Это происходит на оверлее с верхним слоем FUSE, который является слоем, где оверлеи создают новые файлы. Запись доступа к каталогу на таком оверлейе — это все, что нужно пользователю для выполнения двух задач.
Флаги DCACHE_OP_REVALIDATE и DCACHE_OP_WEAK_REVALIDATE. Они сообщают путь, чтобы вызвать ->d_revalidate() или ->d_weak_revalidate() на dentry, так что файловая система может проверить, что кэшированный dentry все еще действителен. Один из этих флагов есть только у накладного флажка, если он есть у накладного флажка в одном из слоев.
У зубцов FUSE есть первый. Когда флажок установлен на оверлейной ленте, путь вызывает ovl_dentry_revalidate_common(). Эта функция только ожидает dentry без inode в RCU, в то время как dentry разрушается.
Для такого дентри за пределами RCU он попадает в WARN_ON () и возвращает -ECHILD. Таким образом, отрицательный оверлей никогда не должен иметь установленные флаги. ovl_instantiate() нарушает это правило. ovl_instantiate(), то работает в таком порядке: - It копирует флаги из нового верхнего dentry в оверлейный dentry. - It вызывает ovl_get_inode(), который может спать в запросе getxattr на сервер FUSE. - Only затем вызывает d_instantiate(). Вторая задача, которая ищет имя между первым шагом и последним, находит отрицательное Dentry с установленными флагами и повторно подтверждает его.
Воспроизводится с сервером FUSE, который задерживает свой ответ getxattr: stat() имени, которое было создано, попало в WARN_ON() и потерпело неудачу с ECHILD. Исправьте это, установив флаги после d_instantiate().
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: ovl: set the revalidate flags after d_instantiate() stat() of a file on an overlayfs mount triggers a kernel warning and fails with ECHILD if another task is creating that file at the same time. This happens on an overlay with a FUSE upper layer, which is the layer where overlayfs creates new files. Write access to a directory on such an overlay is all a user needs to run the two tasks. The revalidate flags are DCACHE_OP_REVALIDATE and DCACHE_OP_WEAK_REVALIDATE. They tell path walk to call ->d_revalidate() or ->d_weak_revalidate() on a dentry, so that the filesystem can check that the cached dentry is still valid. An overlay dentry only has one of these flags if a dentry in one of its layers has it. FUSE dentries have the first one. When a flag is set on an overlay dentry, path walk calls ovl_dentry_revalidate_common(). That function only expects a dentry without an inode in RCU walk, while the dentry is being destroyed. For such a dentry outside of RCU walk, it hits a WARN_ON() and returns -ECHILD. So a negative overlay dentry must never have the flags set. ovl_instantiate() breaks this rule. When a task creates a file, the overlay dentry for the new name is hashed but still negative. ovl_instantiate() then works in this order: - It copies the flags from the new upper dentry to the overlay dentry. - It calls ovl_get_inode(), which can sleep in a getxattr request to the FUSE server. - Only then does it call d_instantiate(). A second task that looks up the name between the first step and the last finds a negative dentry with the flags set and revalidates it. Reproduced with a FUSE server that delays its getxattr reply: stat() of a name that was being created hit the WARN_ON() and failed with ECHILD. Fix this by setting the flags after d_instantiate().