-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conversation
lib/wasi.c
Outdated
int ret = 0; /* never fail */ | ||
HOST_FUNC_RESULT_SET(ft, results, 0, i32, | ||
wasi_convert_errno(ret)); | ||
} | ||
return 0; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
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
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