In the Linux kernel, the following vulnerability has been resolved: mm/shmem: make shmem_file() check the file's inode shmem_file() only checks if file->f_mapping is a shmem mapping. Однако это отображение может принадлежать другому файлу, как и файл Coda, поддерживаемый контейнером tmpfs после mmap(). Таким образом, это не гарантирует, что файл inode является фактическим shmem inode.
Обработка уплотнений и сохранение memfd используют эту проверку перед доступом к состоянию inode shmem, поэтому они могут получить доступ к inode неправильного типа. Давайте заставим shmem_file() вместо этого проверить файловые операции inode, чтобы надежно идентифицировать shmem inodes. Это позволит идентифицировать обычные shmem inodes, включая memfds и обычные tmpfs-файлы, независимо от операций с файлами обёртки.
Вместо этого используйте shmem_mapping() в collapse_file(), чтобы не изменять поведение collapse_file(): он работает в кэше страницы и использует mapping->host для операций shmem inode. Сосредоточение внимания на файле не кажется уместным.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: mm/shmem: make shmem_file() check the file's inode shmem_file() only checks if file->f_mapping is a shmem mapping. This mapping can belong to another file, however, as with a Coda file backed by a tmpfs container after mmap(). So it does not guarantee that the file inode is an actual shmem inode. Seal handling and memfd preservation use this check before accessing shmem inode state, so they can access an inode of the wrong type. Let's make shmem_file() check the inode's file operations instead, to identify shmem inodes reliably. This will identify regular shmem inodes, including memfds and ordinary tmpfs files, independently of wrapper file operations. Use shmem_mapping() in collapse_file() instead to not change the behavior of collapse_file(): it operates on the page cache and uses mapping->host for shmem inode operations. Focusing on the file does not seem relevant.