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

wasi: raise a trap on out-of-range memory access #2

Merged
merged 3 commits into from
Jan 14, 2023
Merged

Conversation

yamt
Copy link
Owner

@yamt yamt commented Jan 14, 2023

The previous logic was broken.
It was returning EFAULT (which indicating a trap in memory_getptr) to the caller without processing the trap properly.

This commit fixes it by distinguishing user-level error and host-level error. EFAULT for traps is a host-level error.

cf. WebAssembly/WASI#505

lib/wasi.c Outdated
int ret = 0; /* never fail */
HOST_FUNC_RESULT_SET(ft, results, 0, i32,
wasi_convert_errno(ret));
}
return 0;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

host_ret

lib/wasi.c Outdated
if (host_ret == 0) {
HOST_FUNC_RESULT_SET(ft, results, 0, i32,
wasi_convert_errno(ret));
}
return 0;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

host_ret

lib/wasi.c Outdated
if (host_ret == 0) {
HOST_FUNC_RESULT_SET(ft, results, 0, i32,
wasi_convert_errno(ret));
}
return 0;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

host_ret

pathlen1, &wasmpath1, &hostpath1);
if (ret != 0) {
int host_ret;
int ret = 0;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary initialization as wasi_copyin_and_convert_path always set ret.

yamt added 3 commits January 14, 2023 18:20
The previous logic was broken.
It was returning EFAULT (which indicating a trap in memory_getptr)
to the caller without processing the trap properly.

This commit fixes it by distinguishing user-level error and
host-level error. EFAULT for traps is a host-level error.

cf. WebAssembly/WASI#505
@yamt yamt merged commit af85f11 into master Jan 14, 2023
@yamt yamt deleted the wasi-efault branch January 14, 2023 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant