-
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
Disallow values to cross stores #1016
Disallow values to cross stores #1016
Conversation
crates/api/src/values.rs
Outdated
pub(crate) fn comes_from_same_store(&self, store: &Store) -> bool { | ||
match self { | ||
Val::FuncRef(f) => Store::same(store, f.store()), | ||
_ => true, |
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.
It'd be helpful to have a brief comment here, mentioning that none of the numeric value types inherently depend on a store.
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.
I went ahead and opted to switch this to an exhaustive match and added a comment for integers
crates/api/src/values.rs
Outdated
pub(crate) fn comes_from_same_store(&self, store: &Store) -> bool { | ||
match self { | ||
Val::FuncRef(f) => Store::same(store, f.store()), | ||
_ => true, |
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.
Do we need to handle AnyRef
here too, for the InternalRef
case?
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.
Currently it technically doesn't need to because we don't really support anyref
in wasmtime at the moment. I went ahead and explicitly matched it to always return false
with a TODO comment about how to fix it in the future.
630dbd1
to
008a3f6
Compare
Lots of internals in the wasmtime-{jit,runtime} crates are highly unsafe, so it's up to the `wasmtime` API crate to figure out how to make it safe. One guarantee we need to provide is that values never cross between stores. For example you can't take a function in one store and move it over into a different instance in a different store. This dynamic check can't be performed at compile time and it's up to `wasmtime` to do the check itself. This adds a number of checks, but not all of them, to the codebase for now. This primarily adds checks around instantiation, globals, and tables. The main hole in this is functions, where you can pass in arguments or return values that are not from the right store. For now though we can't compile modules with `anyref` parameters/returns anyway, so we should be good. Eventually when that is supported we'll need to put the guards in place. Closes bytecodealliance#958
008a3f6
to
5051295
Compare
Turns out this was a typo from bytecodealliance#1016!
Turns out this was a typo from #1016!
Lots of internals in the wasmtime-{jit,runtime} crates are highly
unsafe, so it's up to the
wasmtime
API crate to figure out how to makeit safe. One guarantee we need to provide is that values never cross
between stores. For example you can't take a function in one store and
move it over into a different instance in a different store. This
dynamic check can't be performed at compile time and it's up to
wasmtime
to do the check itself.This adds a number of checks, but not all of them, to the codebase for
now. This primarily adds checks around instantiation, globals, and
tables. The main hole in this is functions, where you can pass in
arguments or return values that are not from the right store. For now
though we can't compile modules with
anyref
parameters/returns anyway,so we should be good. Eventually when that is supported we'll need to
put the guards in place.
Closes #958