Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cyphar opened this issue Oct 1, 2024 · 4 comments
Open

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

cyphar opened this issue Oct 1, 2024 · 4 comments
Labels
A-files Area: related to files, paths, sockets, file descriptors, or handles A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement S-blocked Status: blocked on something happening somewhere else

Comments

@cyphar
Copy link

cyphar commented Oct 1, 2024

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
Copy link
Author

cyphar commented Oct 1, 2024

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 cyphar changed the title [ffi request] support renameat2 unsupported operation: renameat2, openat, openat2, ... Oct 1, 2024
@RalfJung
Copy link
Member

RalfJung commented Oct 2, 2024

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

@RalfJung RalfJung added C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement A-shims Area: This affects the external function shims A-files Area: related to files, paths, sockets, file descriptors, or handles S-blocked Status: blocked on something happening somewhere else labels Oct 2, 2024
@cyphar
Copy link
Author

cyphar commented Oct 2, 2024

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
Copy link
Member

RalfJung commented Oct 2, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-files Area: related to files, paths, sockets, file descriptors, or handles A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement S-blocked Status: blocked on something happening somewhere else
Projects
None yet
Development

No branches or pull requests

2 participants