miri icon indicating copy to clipboard operation
miri copied to clipboard

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

Open cyphar opened this issue 1 year ago • 4 comments

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 avatar Oct 01 '24 23:10 cyphar

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)...

cyphar avatar Oct 01 '24 23:10 cyphar

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.

RalfJung avatar Oct 02 '24 06:10 RalfJung

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!

cyphar avatar Oct 02 '24 08:10 cyphar

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

RalfJung avatar Oct 02 '24 09:10 RalfJung