-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
abolish Z_OOPS() in system call handlers #17735
Comments
Has a dependency on #16702 |
Proposed error conditions returned, for any API exposed as system call. Most of these checks can only be determined if invoked from user mode. Note that we have some syscalls which return pointers and will require some thought on how to propagate stuff, for the moment we'll just have to return NULL:
|
Another thing that needs fixing: Z_SYSCALL_VERIFY(), Z_SYSCALL_OBJ, Z_SYSCALL_MEMORY and related functions do something goofy: they expect their input to be a function which returns 0 on success and nonzero on failure. Z_SYSCALL_VERIFY() casts this to a boolean and then inverts its value, returning False on success and True on failure. Probably need to provide new versions of these. They can be expressed as inline functions instead of macros I think since SSF is no longer passed around. |
Questions to answer:
|
My initial feelings on the above post, which are certainly subject to persuasion:
|
Big big questions to answer:
For example, we might decide to leave the EACCES, EBADF, EFAULT, ENOSYS, EADDRINUSE, and EINVAL (uniitialized object) cases as Z_OOPS(), in which case most syscalls will not need an API change. |
Not so sure about this. Most 'new' error codes proposed would be systematic/design errors, that should never happen. Error return codes might not always be checked, introducing more latent problems. Would recovery be really easier with return values, or would the Z_OOPS simply be called by the application code that now needs to check for these errors? |
@ruuddw I agree. And I spoke with @ceolin some more, we think we don't have specific fusa requirements to return values, killing the caller is acceptable as well. So in the end we may not do much here. I think it helps to decompose this into categories. Using my previous post of return codes as a starting point:
I think for categories 1, 2, and 3, these are purely programming mistakes. We could continue to raise For category 4, these return errors. In the past, many of these were left as assertions, but are now more robustly checked with For category 5, checks that currently only happen when invoked from user mode are currently usually failed with For category 6, I think |
Sounds like a good refinement, indeed ENOMEM is an example of a possible transient fault: if the caller tries again (maybe after cleaning something up) it could be recoverable. |
As described in zephyrproject-rtos#17735. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
As described in #17735. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
As described in zephyrproject-rtos#17735. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
If a user thread passes incorrect parameters to a system call, in most cases this will trigger a fatal exception with Z_OOPS() instead of returning an error.
This was done to keep kernel APIs exactly the same, as many did not propagate return values either. However we should provide opportunities for recovery, and not unconditionally explode like this, it's not good from a FuSa perspective and is fundamentally user-hostile.
For common errors like kernel object or memory buffer permissions, standardize on a set of errno codes for these and be consistent across system calls when these issues occur.
Change system call handlers to return an error value instead. This is related work to #16702
The text was updated successfully, but these errors were encountered: