In the Linux kernel, the following vulnerability has been resolved: ovl: fix whiteout creation in casefolded directories unlink and rmdir fail with EINVAL on an overlay with casefolded (case-insensitive) layers, if the name exists in a lower layer. Слои Casefolded нуждаются в CONFIG_UNICODE. Root может монтировать такой оверлей, как и непривилегированный пользователь в пространстве имен пользователя, со слоями tmpfs.
Overlayfs не изменяет нижний слой. Чтобы удалить имя, которое существует там, он скрывает имя с помощью файла маркера, белого пятна. Он создает отсечение в рабочем каталоге, скретч-каталог в верхней файловой системе и переименовывает его по имени в верхнем каталоге: - ovl_whiteout () создает отсечение с mknod или в качестве жесткой ссылки на более раннее отсечение. - ovl_cleanup_and_whiteout () затем готовит переименование с start_renaming_two_dentries (), который возвращает -EINVAL, если исходный или целевой dentry не размещен, dentry.
С каталогами со сложенными регистрами, оба зубца могут быть неразборчивы: - Цель. Поиск в папке со свернутым регистром оставляет отрицательный dentry невозмутимым, поэтому цель переименования невозмутима, если имя не существует в верхней директории. - Источник, который является новым whiteout. tmpfs hashes a dentry, когда mknod или ссылка делают его положительным, но ext4 не делает, поэтому на ext4 источник также невозмутим. Очистка после сбоя также отказывает невозмутимому дентри, поэтому на ext4 отсечение остается позади в рабочем каталоге.
Воспроизводится с rm и rmdir на слоях tmpfs и ext4, также как uid 1000 в пространстве имен пользователей. Исправьте это, создав отбеливание с помощью ovl_create_temp (), который повторяет поиск, если новый дентри невозмутим. Подготовьте переименовывание с помощью start_renaming_dentry (), который ищет целевое имя с заблокированными каталогами.
Звонивший просматривал имя без замка, поэтому возвращайте -ESTALE, если имя теперь относится к другому inode. [amir: передайте имя, используемое для поиска, вместо того, чтобы делать снимок имени]
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: ovl: fix whiteout creation in casefolded directories unlink and rmdir fail with EINVAL on an overlay with casefolded (case-insensitive) layers, if the name exists in a lower layer. Casefolded layers need CONFIG_UNICODE. Root can mount such an overlay, and so can an unprivileged user in a user namespace, with tmpfs layers. Overlayfs does not change a lower layer. To remove a name that exists there, it hides the name with a marker file, a whiteout. It creates the whiteout in the work directory, a scratch directory on the upper filesystem, and renames it over the name in the upper directory: - ovl_whiteout() creates the whiteout with mknod, or as a hard link to an earlier whiteout. - ovl_cleanup_and_whiteout() then prepares the rename with start_renaming_two_dentries(), which returns -EINVAL if the source or the target dentry is unhashed, that is, not in the dentry hash table. With casefolded directories, both dentries can be unhashed: - The target. Lookup in a casefolded directory leaves a negative dentry unhashed, so the rename target is unhashed if the name does not exist in the upper directory. - The source, which is the new whiteout. tmpfs hashes a dentry when mknod or link makes it positive, but ext4 does not, so on ext4 the source is unhashed as well. The cleanup after the failure also refuses an unhashed dentry, so on ext4 the whiteout is left behind in the work directory. Reproduced with rm and rmdir on casefolded tmpfs and ext4 layers, also as uid 1000 in a user namespace. Fix this by creating the whiteout with ovl_create_temp(), which repeats the lookup if the new dentry is unhashed. Prepare the rename with start_renaming_dentry(), which looks up the target name with the directories locked. The caller looked the name up without a lock, so return -ESTALE if the name now refers to a different inode. [amir: pass the name used for lookup instead of taking a name snapshot]