rust-lang / miri

An interpreter for Rust's mid-level intermediate representation
Apache License 2.0
4.38k stars 339 forks source link

unsupported operation: renameat2, openat, openat2, ... #3931

Open cyphar opened 17 hours ago

cyphar commented 17 hours ago

libc::renameat2 is a fairly commonly used function on Linux (especially since it is the only way of doing atomic file swaps on Linux with RENAME_EXCHANGE) that Miri does not yet support:

test flags::tests::rename_flags_is_supported ... error: unsupported operation: can't call foreign function `renameat2` on OS `linux`
   --> src/syscalls.rs:602:9
    |
602 | /         libc::renameat2(
603 | |             olddirfd.as_raw_fd(),
604 | |             oldpath.to_c_string().as_ptr(),
605 | |             newdirfd.as_raw_fd(),
606 | |             newpath.to_c_string().as_ptr(),
607 | |             flags,
608 | |         )
    | |_________^ can't call foreign function `renameat2` on OS `linux`
    |
    = help: if this is a basic API commonly used on this target, please report an issue with Miri
    = help: however, note that Miri does not aim to support every FFI function out there; for instance, we will not support APIs for things such as GUIs, scripting languages, or databases
% cargo +nightly --version
cargo 1.83.0-nightly (80d82ca22 2024-09-27)
% cargo +nightly miri --version
miri 0.1.0 (fb4aebd 2024-09-30)
cyphar commented 17 hours ago

Ah, it seems openat and openat2 are also missing. I guess that means I can't do Miri tests for https://github.com/openSUSE/libpathrs since openat and openat2 are used everywhere throughout it (since it's a filesystem-related library)...

RalfJung commented 11 hours ago

Yeah, those are all waiting for https://github.com/rust-lang/rust/issues/120426 so that we can implement them on top of standard library APIs.

cyphar commented 8 hours ago

Funnily enough, the library I was trying to verify with miri is a crate for sandboxing path operations (of the kind mentioned in that issue). 😅

I'll keep an eye out for this. Thanks!

RalfJung commented 7 hours ago

Ah, in that case maybe even DirFd won't be enough...