Skip to content

Commit bf44bac

Browse files
lpereiraandrewboie
authored andcommitted
kernel: mutex: Copy assertions to assertions to syscall handler
Always ensure that the mutex owner is the current thread and that the count is sane. Signed-off-by: Leandro Pereira <[email protected]>
1 parent 361ef34 commit bf44bac

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

kernel/mutex.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,5 +256,12 @@ void _impl_k_mutex_unlock(struct k_mutex *mutex)
256256
}
257257

258258
#ifdef CONFIG_USERSPACE
259-
_SYSCALL_HANDLER1_SIMPLE_VOID(k_mutex_unlock, K_OBJ_MUTEX, struct k_mutex *);
259+
_SYSCALL_HANDLER(k_mutex_unlock, mutex)
260+
{
261+
_SYSCALL_OBJ(mutex, K_OBJ_MUTEX);
262+
_SYSCALL_VERIFY(((struct k_mutex *)mutex)->lock_count > 0);
263+
_SYSCALL_VERIFY(((struct k_mutex *)mutex)->owner == _current);
264+
_impl_k_mutex_unlock((struct k_mutex *)mutex);
265+
return 0;
266+
}
260267
#endif

0 commit comments

Comments
 (0)