Skip to content

Commit af2a60d

Browse files
RoyLinRoyLin
authored andcommitted
fix(macos): avoid double-closing virtiofs descriptors
1 parent f01be57 commit af2a60d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/devices/src/virtio/fs/macos/passthrough.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,10 +2063,10 @@ impl FileSystem for PassthroughFs {
20632063
return Err(linux_error(io::Error::last_os_error()));
20642064
}
20652065

2066-
let ret = unsafe { libc::close(fd) };
2067-
if ret == -1 {
2068-
return Err(linux_error(io::Error::last_os_error()));
2069-
}
2066+
// `file` owns `fd` and closes it on drop. Closing the raw descriptor
2067+
// here as well races with descriptor reuse and can close an unrelated
2068+
// virtio-fs handle, surfacing in the guest as sporadic EBADF on tar's
2069+
// close(). This mirrors the Linux fix in 27910fe.
20702070

20712071
// We've checked that map_sender is something above.
20722072
let sender = map_sender.as_ref().unwrap();

0 commit comments

Comments
 (0)