From 6e28d809277042a4a83762f61a8c623155849bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sun, 7 Jan 2018 22:32:44 +0100 Subject: [PATCH] kernel: port: check USE_USER_COPY flag before masking it. writev_port_etc() used memcpy() instead of user_memcpy() for user buffers. The branch was even left out silently as an optimization on gcc5. --- src/system/kernel/port.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/port.cpp b/src/system/kernel/port.cpp index e9dff1780b..26e00d26ed 100644 --- a/src/system/kernel/port.cpp +++ b/src/system/kernel/port.cpp @@ -1563,6 +1563,8 @@ writev_port_etc(port_id id, int32 msgCode, const iovec* msgVecs, if (bufferSize > PORT_MAX_MESSAGE_SIZE) return B_BAD_VALUE; + bool userCopy = (flags & PORT_FLAG_USE_USER_MEMCPY) != 0; + // mask irrelevant flags (for acquire_sem() usage) flags &= B_CAN_INTERRUPT | B_KILL_CAN_INTERRUPT | B_RELATIVE_TIMEOUT | B_ABSOLUTE_TIMEOUT; @@ -1574,8 +1576,6 @@ writev_port_etc(port_id id, int32 msgCode, const iovec* msgVecs, timeout += system_time(); } - bool userCopy = (flags & PORT_FLAG_USE_USER_MEMCPY) > 0; - status_t status; port_message* message = NULL;