Skip to content

Commit e304726

Browse files
[29.0.x]: Fix a missing increment in p1-to-p2 adapter (#10067)
* Add audit for `wasmtime-math` (#10059) I noticed that CI is failing given that an audit and policy for `wasmtime-math` is missing. `wasmtime-math` was introduced in https://github.com/bytecodealliance/wasmtime/pull/9808/files. I followed a similar approach to what it's used for all the other `wasmtime-*` crates. * Fix a missing increment in p1-to-p2 adapter (#10064) This commit fixes a bug in the WASIp1-to-WASIp2 adapter during `fd_prestat_dir_name` where an iterator variable was forgotten to be incremented. That means that getting the path for anything other than the first preopen didn't work correctly. Closes #10058 * Downgrade `wasip2` dep to 0.13.0 Compat with 1.81.0 MSRV --------- Co-authored-by: Saúl Cabrera <saulecabrera@gmail.com>
1 parent 5454077 commit e304726

File tree

8 files changed

+111
-5
lines changed

8 files changed

+111
-5
lines changed

Cargo.lock

Lines changed: 24 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/test-programs/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ futures = { workspace = true, default-features = false, features = ['alloc'] }
2121
url = { workspace = true }
2222
sha2 = "0.10.2"
2323
base64 = "0.21.0"
24+
wasip2 = { version = "0.13.0", package = 'wasi' }
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use std::str;
2+
3+
fn main() {
4+
dbg!(wasip2::filesystem::preopens::get_directories());
5+
unsafe {
6+
let p3 = wasi::fd_prestat_get(3).unwrap();
7+
let p4 = wasi::fd_prestat_get(4).unwrap();
8+
let p5 = wasi::fd_prestat_get(5).unwrap();
9+
assert_eq!(wasi::fd_prestat_get(6).err().unwrap(), wasi::ERRNO_BADF);
10+
11+
assert_eq!(p3.u.dir.pr_name_len, 2);
12+
assert_eq!(p4.u.dir.pr_name_len, 2);
13+
assert_eq!(p5.u.dir.pr_name_len, 2);
14+
15+
let mut buf = [0; 100];
16+
17+
wasi::fd_prestat_dir_name(3, buf.as_mut_ptr(), buf.len()).unwrap();
18+
assert_eq!(str::from_utf8(&buf[..2]).unwrap(), "/a");
19+
wasi::fd_prestat_dir_name(4, buf.as_mut_ptr(), buf.len()).unwrap();
20+
assert_eq!(str::from_utf8(&buf[..2]).unwrap(), "/b");
21+
wasi::fd_prestat_dir_name(5, buf.as_mut_ptr(), buf.len()).unwrap();
22+
assert_eq!(str::from_utf8(&buf[..2]).unwrap(), "/c");
23+
assert_eq!(
24+
wasi::fd_prestat_dir_name(6, buf.as_mut_ptr(), buf.len()),
25+
Err(wasi::ERRNO_BADF),
26+
);
27+
}
28+
// ..
29+
}

crates/wasi-preview1-component-adapter/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ impl ImportAlloc {
404404
ImportAlloc::GetPreopenPath { cur, nth, alloc } => {
405405
if align == 1 {
406406
let real_alloc = *nth == *cur;
407+
*cur += 1;
407408
if real_alloc {
408409
alloc.alloc(align, size)
409410
} else {

supply-chain/audits.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,14 @@ start = "2022-11-21"
489489
end = "2025-07-30"
490490
notes = "The Bytecode Alliance is the author of this crate."
491491

492+
[[wildcard-audits.wasmtime-math]]
493+
who = "Saúl Cabrera <saulecabrera@gmail.com>"
494+
criteria = "safe-to-deploy"
495+
user-id = 73222 # wasmtime-publish
496+
start = "2025-01-20"
497+
end = "2026-01-21"
498+
notes = "The Bytecode Alliance is the author of this crate."
499+
492500
[[wildcard-audits.wasmtime-runtime]]
493501
who = "Bobby Holley <bobbyholley@gmail.com>"
494502
criteria = "safe-to-deploy"
@@ -4457,6 +4465,12 @@ user-id = 1 # Alex Crichton (alexcrichton)
44574465
start = "2020-06-03"
44584466
end = "2025-12-05"
44594467

4468+
[[trusted.wasi]]
4469+
criteria = "safe-to-deploy"
4470+
user-id = 6825 # Dan Gohman (sunfishcode)
4471+
start = "2019-07-22"
4472+
end = "2026-01-21"
4473+
44604474
[[trusted.wasm-bindgen]]
44614475
criteria = "safe-to-deploy"
44624476
user-id = 1 # Alex Crichton (alexcrichton)

supply-chain/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ audit-as-crates-io = true
142142
[policy.wasmtime-jit-icache-coherence]
143143
audit-as-crates-io = true
144144

145+
[policy.wasmtime-math]
146+
audit-as-crates-io = true
147+
145148
[policy.wasmtime-slab]
146149
audit-as-crates-io = true
147150

supply-chain/imports.lock

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,14 @@ audited_as = "26.0.1"
257257
version = "29.0.0"
258258
audited_as = "27.0.0"
259259

260+
[[unpublished.wasmtime-jit-icache-coherence]]
261+
version = "30.0.0"
262+
audited_as = "28.0.0"
263+
264+
[[unpublished.wasmtime-math]]
265+
version = "30.0.0"
266+
audited_as = "29.0.0"
267+
260268
[[unpublished.wasmtime-slab]]
261269
version = "28.0.0"
262270
audited_as = "26.0.1"
@@ -1132,6 +1140,13 @@ user-id = 1
11321140
user-login = "alexcrichton"
11331141
user-name = "Alex Crichton"
11341142

1143+
[[publisher.wasi]]
1144+
version = "0.13.3+wasi-0.2.2"
1145+
when = "2024-10-08"
1146+
user-id = 1
1147+
user-login = "alexcrichton"
1148+
user-name = "Alex Crichton"
1149+
11351150
[[publisher.wasi-common]]
11361151
version = "27.0.0"
11371152
when = "2024-11-20"
@@ -1299,6 +1314,12 @@ when = "2024-11-20"
12991314
user-id = 73222
13001315
user-login = "wasmtime-publish"
13011316

1317+
[[publisher.wasmtime-math]]
1318+
version = "29.0.0"
1319+
when = "2025-01-20"
1320+
user-id = 73222
1321+
user-login = "wasmtime-publish"
1322+
13021323
[[publisher.wasmtime-slab]]
13031324
version = "27.0.0"
13041325
when = "2024-11-20"
@@ -1609,6 +1630,12 @@ when = "2024-11-13"
16091630
user-id = 73222
16101631
user-login = "wasmtime-publish"
16111632

1633+
[[publisher.wit-bindgen-rt]]
1634+
version = "0.33.0"
1635+
when = "2024-09-30"
1636+
user-id = 73222
1637+
user-login = "wasmtime-publish"
1638+
16121639
[[publisher.wit-bindgen-rt]]
16131640
version = "0.35.0"
16141641
when = "2024-11-13"

tests/all/cli_tests.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,6 +2059,18 @@ after empty
20592059
])?;
20602060
Ok(())
20612061
}
2062+
2063+
#[test]
2064+
fn cli_multiple_preopens() -> Result<()> {
2065+
run_wasmtime(&[
2066+
"run",
2067+
"--dir=/::/a",
2068+
"--dir=/::/b",
2069+
"--dir=/::/c",
2070+
CLI_MULTIPLE_PREOPENS_COMPONENT,
2071+
])?;
2072+
Ok(())
2073+
}
20622074
}
20632075

20642076
#[test]

0 commit comments

Comments
 (0)