-
Notifications
You must be signed in to change notification settings - Fork 8k
userspace: Additional checks in K_SYSCALL_MEMORY #65546
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
userspace: Additional checks in K_SYSCALL_MEMORY #65546
Conversation
Hmm. So some of our APIs actually allow passing in a zero length (e.g. the EEPROM API) and this is tested (in test_zero_length_write, which now fails the test case due to these changes). |
the problem is that |
b584c13
7e441c1
to
b584c13
Compare
@henrikbrixandersen I end up adding a redundant check in these APIs since I think it is better to have that 0 length check in that macro to avoid any undefined behavior. |
There are many api's having the same problem with the length 0 check (flash, bbram, retained_mem, ...). It would be better to correct it at the |
if we change I can remove the |
Writing/reading with 0 length memory in all cases I know means: do nothing. A well written driver will not do anything in this case. In practice this will never be used. I don't understand why all drivers try to catch this early, this is just extra code that is never used in practice. The |
This macros needed additional checks before invoking arch_buffer_validate. - size can not be less then 0. Some functions invoke this macro using signed type which will be promote to unsigned when invoking arch_buffer_validate. We need to do an early check. - We need to check for possible overflow, since a malicious user application could use a negative number that would be promoted to a big value that would cause a integer overflow when adding it to the buffer address, leading to invalid checks. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
b584c13
to
3fcb96a
Compare
I have dropped the check "> 0" since there are APIs relying on it. Instead I changed ">= 0" that fix the real problem because some functions invoke this macro using signed type which will be promote to unsigned when invoking arch_buffer_validate. |
@ceolin This change seems to have triggered many Coverity CID issues. |
Same for me, |
This macros needed additional checks before invoking arch_buffer_validate.