-
Notifications
You must be signed in to change notification settings - Fork 258
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
Document that an out-of-bounds pointer shall trap #536
Conversation
Looks good to me. I'll leave this open for a while in case there are any other comments. |
This is a change of behavior for Should we specify the behavior for passing pointers with an incorrect alignment? Do we need to clarify this spec test to include behaviors for chasing pointers that are out-of-bounds? Do we need to trap before any other observable side effects, e.g. do we need to validate that all memory referred to in a iovec is in bounds before writing any outputs? |
The Canonical ABI is currently proposed to trap on misaligned pointers, so yes, I'd say we should ideally do that here too.
Which spec test are you referring to?
If we're going to trap, we should trap before any observable side effects. Should we trap for an iovec with any buffer out of bounds? The component model doesn't yet have an iovec, so it doesn't have an opinion here yet. POSIX doesn't appear to say anything. Linux's |
i don't think it's a good idea to require eager checks.
some implementations naturally ignore unused iovecs eg. on a short read. |
Typo, i meant It sounds like Linux is eager about returning a fault on invalid iovec pointers. @yamt are you aware of other operating systems which are lazier about this behavior, or is it just other wasi preview 1 implementations? I am in favor of being eager about that fault in order to align with the component model - in preview 2 it will be eager no matter what. |
eg. netbsd and as far as i tested with the following test code, linux doesn't seem eager either. |
@@ -77,6 +77,10 @@ For example, the `poll_oneoff` function has these arguments: | |||
Pointer values are expected to be aligned, to the alignment of their pointee | |||
type. If a misaligned pointer is passed to a function, the function shall trap. |
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.
@pchickey misaligned pointer is documented here
Oh, interesting. If I modify your testcase to use With
With
So I don't know what logic Linux is using to decide what gets an I think WASI should be eager here.
|
interesting.
i'm not sure about this "lazy checking wouldn't save" point.
|
That's a good point. Some implementations could have some extra cost to this. Fortunately, So I'd still say that the security and portable angles justify eager trapping here, especially this time. It will catch some cases where programs might be implicitly depending on |
This has been open for a while (unfortuantely I lost track of it) and we haven't seen any objections, so I am merging |
discussion: #505