-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Improper resolution of .. components in symlinks #9272
Comments
Thanks for the report! Would you be able to gist exactly what
That may mean that the difference boils down to what Rust and Go are doing, and so the next step here would be to narrow in on that and see what's going on. If you're able to upload the Go-generated wasm binary here that would also help too |
The wasmtime command is from here: https://go.googlesource.com/go/+/refs/tags/go1.23.0/misc/wasm/go_wasip1_wasm_exec
Wasm binary I'm using: |
Hm I actually can't seem to reproduce with the binary that you provided. I get:
which I think means that it's working? I noticed above sometimes the symlink was called "up" and sometimes it was "upa". I mixed the two up and thought Rust was working and Go wasn't but then when I fixed the name they both worked. Mind double-checking on your end too? |
Setup:
And running:
This is on macOS. I had thought I'd observed this on macOS and Linux, but I just rechecked and I can't reproduce on Linux. So perhaps macOS-specific? Or possibly even Linux version specific, if wasmtime uses openat2 with RESOLVE_BENEATH when available. |
Aha the plot thickens! I was indeed testing on Linux. I'll work next week on digging more into macOS, as I suspect you're right this is macOS-specific behavior. |
I can reproduce the problem using cap-std directly with this example: use std::io::Read;
fn main() {
let path = "b/up/target";
let dir = cap_std::fs::Dir::open_ambient_dir(".", cap_std::ambient_authority()).unwrap();
let mut file = dir.open(path).unwrap();
let mut s = String::new();
file.read_to_string(&mut s).unwrap();
eprintln!("read: {:?}", s);
} If I modify cap-std to avoid using |
When `..` appears at the end of a symlink target, but is not at the end of the full path target, don't mark the path as being expected to open a directory. This fixes the reduced testcase in bytecodealliance/wasmtime#9272.
* Fix handling of `..` paths in symlinks. When `..` appears at the end of a symlink target, but is not at the end of the full path target, don't mark the path as being expected to open a directory. This fixes the reduced testcase in bytecodealliance/wasmtime#9272. * Update CI to macos-12.
cap-std 3.3.0 contains bytecodealliance/cap-std#366, which fixes bytecodealliance#9272, which is about the handling of `..` in symlink destinations.
I've now submitted #9307 which should fix this issue. |
* Update to cap-std 3.3.0. cap-std 3.3.0 contains bytecodealliance/cap-std#366, which fixes #9272, which is about the handling of `..` in symlink destinations. * Add wildcard vet of pulley --------- Co-authored-by: Alex Crichton <[email protected]>
I believe I've run across a bug in wasmtime's handling of symlink targets which include
".."
. I've reproduced this using the Go program below which callspath_open
on a path and reports the result. It's not the simplest test program, but it avoids dependencies and I have a Go compiler handy.Simple case, no bug:
The bug shows up when resolving a link with a target of
".."
:I'm not sure exactly what is going awry, but the "not a directory" error is clearly wrong. Note that we can open
b/up
(resolves to.
as expected). The problem seems to be specific to links that end in..
: if we change the link target to../a
, everything works as expected:Test program:
The text was updated successfully, but these errors were encountered: