kernel: Fix overflow test problem introduced in 92ea2f9
The builtin function __builtin_umul_overflow returns a boolean and should not checked as an integer. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
57a8db7789
commit
18af4c6299
3 changed files with 6 additions and 6 deletions
|
@ -351,9 +351,9 @@ bool z_syscall_verify_msg(bool expr, const char *fmt, ...)
|
|||
#define Z_SYSCALL_MEMORY_ARRAY(ptr, nmemb, size, write) \
|
||||
({ \
|
||||
u32_t product; \
|
||||
Z_SYSCALL_VERIFY_MSG(__builtin_umul_overflow((u32_t)(nmemb), \
|
||||
Z_SYSCALL_VERIFY_MSG(!__builtin_umul_overflow((u32_t)(nmemb), \
|
||||
(u32_t)(size), \
|
||||
&product) == 0,\
|
||||
&product), \
|
||||
"%ux%u array is too large", \
|
||||
(u32_t)(nmemb), (u32_t)(size)) || \
|
||||
Z_SYSCALL_MEMORY(ptr, product, write); \
|
||||
|
|
|
@ -259,9 +259,9 @@ Z_SYSCALL_HANDLER(k_poll, events, num_events, timeout)
|
|||
goto out;
|
||||
}
|
||||
if (Z_SYSCALL_VERIFY_MSG(
|
||||
__builtin_umul_overflow(num_events,
|
||||
!__builtin_umul_overflow(num_events,
|
||||
sizeof(struct k_poll_event),
|
||||
&bounds) == 0,
|
||||
&bounds),
|
||||
"num_events too large")) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
|
|
|
@ -463,9 +463,9 @@ Z_SYSCALL_HANDLER(k_thread_create,
|
|||
* size and not allocated in addition to the stack size
|
||||
*/
|
||||
guard_size = (u32_t)K_THREAD_STACK_BUFFER(stack) - (u32_t)stack;
|
||||
Z_OOPS(Z_SYSCALL_VERIFY_MSG(__builtin_uadd_overflow(guard_size,
|
||||
Z_OOPS(Z_SYSCALL_VERIFY_MSG(!__builtin_uadd_overflow(guard_size,
|
||||
stack_size,
|
||||
&total_size) == 0,
|
||||
&total_size),
|
||||
"stack size overflow (%u+%u)", stack_size,
|
||||
guard_size));
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue