openvmm: virtiofs: microVM readdirplus continues listing when child entry aliases open directory node
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- rust
- Área
- operating-systems
Línea de trabajo
Start at vm/devices/virtio/virtiofs/src/lib.rs: Fuse::read_dir and read_dir_plus call file.read_dir without request.node_id(). Then read microvm/file.rs::read_dir_microvm and its lookup_helper loop, and trace InodeMap::insert plus VirtioFsInode::lookup in inode.rs for the path overwrite. Reproduce with the issue's dir/sub/after snapshot; done when a child aliasing the open directory is rejected and later names resolve under the original path.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
In microVM mode, VirtioFsFile::read_dir_microvm resolves each FUSE_READDIRPLUS entry by calling fs.lookup_helper(&self.inode, name) without checking whether the returned fuse_entry.nodeid equals the FUSE node ID of the open directory being enumerated (request.node_id()). If a child directory entry deduplicates onto self.inode's own node ID, InodeMap::insert rewrites self.inode.path from "dir" to "dir/child" in place, read_dir_microvm emits a self-referential child nodeid to the guest, and subsequent loop iterations resolve remaining snapshot names inside "dir/child" instead of "dir". Found by formal verification.
Root Cause
In vm/devices/virtio/virtiofs/src/lib.rs, Fuse::read_dir and Fuse::read_dir_plus do not pass request.node_id() to file.read_dir, and VirtioFsFile::read_dir_microvm accepts any fuse_entry returned by fs.lookup_helper(&self.inode, name) whose attr.ino matches the snapshot:
fn read_dir_plus(&self, request: &Request, arg: &fuse_read_in) -> lx::Result<Vec<u8>> {
if self.is_synthetic_root_handle(request.node_id(), arg.fh) {
return self.read_synthetic_root_dir(arg.offset, arg.size, true);
}
let file = self.get_file(arg.fh)?;
file.read_dir(self, arg.offset, arg.size, true)
}
let fuse_entry = fs.lookup_helper(&self.inode, name)?;
if fuse_entry.attr.ino != entry.guest_inode_id {
return Err(lx::Error::EIO);
}
if !buffer.dir_entry_plus(name, entry.next_cookie, fuse_entry) {
return Err(lx::Error::EIO);
}
When lookup_helper resolves a child directory whose DedupKey matches self.inode (same file type S_IFDIR), InodeMap::insert takes the Entry::Occupied branch and calls VirtioFsInode::lookup, overwriting *self.inode.path.write() = new_path ("dir/child") and returning fuse_entry.nodeid == request.node_id(). Even the existing fuse_entry.attr.ino != entry.guest_inode_id check does not reject the entry when the snapshot already recorded that inode number.
Consequence
On local Linux filesystems (ext4, xfs, btrfs, tmpfs), an open directory file descriptor keeps its (st_dev, st_ino) allocated on the host until closed, preventing immediate (st_dev, st_ino) reuse by a newly created directory on the same device. However, synthetic, network, or FUSE-backed host shares that reuse or synthesize inode numbers, unlinked/retyped directory cases where the backing filesystem reuses (st_dev, st_ino), or nested subvolumes when DedupKey::Ino omits st_dev (for example a btrfs subvolume directory containing a nested subvolume, both having st_ino == 256) can hit this path. When triggered, read_dir_microvm returns a fuse_direntplus entry whose child nodeid equals its parent directory's nodeid (forming a directory cycle in the guest kernel's dcache) and continues iterating the snapshot while &self.inode now points at "dir/child", resolving later entries from the child directory rather than the open directory.
Reproduction
- Create a microVM
VirtioFsshare containing"dir/sub/after". - Insert a directory
VirtioFsInodeat path"dir"withdir_node_idwhoseDedupKeymatches"dir/sub"(modeling(dev, ino)reuse or collision), open it as a directoryVirtioFsFile, and populate its directory snapshot with[".", "..", "sub", "after"]. - Call
file.read_dir(&fs, dir_node_id, 0, 4096, true). - Without the guard,
lookup_helperon"sub"deduplicates ontodir_node_id, rewritesdir_inode's path from"dir"to"dir/sub", emits"sub"withnodeid == dir_node_id, and then resolves"after"against"dir/sub/after"even though"dir/after"does not exist.
Related: #1611, #1605, #1599.
- Lenguaje dominante
- Rust
- Estrellas
- 848
- Forks
- 63
- Merge medio
- 13 h 37 min
- PR fusionados (30 d)
- 571
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/nvx
-
area: ci
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
area: ci
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
openvmm: virtiofs: aggregate synthetic root st_nlink counts single-file shares as subdirectoriesAbiertoarea: openvmm
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
microsoft/nvx#1632 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
area: openvmm
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
microsoft/nvx#1628 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
area: openvmm
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
microsoft/nvx#1629 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/nvx
Issues similares
-
priority: low
Dificultad 1/5 1-3 horas Aptitud para principiantes 83/100
storytold/vectorcraft#8387 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
area:desktop kind:test priority:p3 ready
Dificultad 2/5 1-3 horas Aptitud para principiantes 91/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
obi1kenobi/cargo-semver-checks#1814 ·
Los mantenedores suelen responder en 1 día
-
COMPARE.md symlink is brokenAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
BurntSushi/jiff#715 ·
Los mantenedores suelen responder en 1 día