From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxJsC-0006GK-Ti for qemu-devel@nongnu.org; Tue, 26 May 2015 14:46:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxJsA-0007wn-UL for qemu-devel@nongnu.org; Tue, 26 May 2015 14:46:44 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:34279) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxJsA-0007uE-NV for qemu-devel@nongnu.org; Tue, 26 May 2015 14:46:42 -0400 From: Peter Maydell Date: Tue, 26 May 2015 19:46:30 +0100 Message-Id: <1432665992-32622-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 0/2] linux-user: Fix length handling in cmsg conversions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Riku Voipio , patches@linaro.org This patchset fixes some problems in conversions of cmsg structures in target_to_host_cmsg() (used in send/recvmsg handling). Specifically: * we required the msg->msg_controllen to declare the buffer to have enough space for final trailing padding (we were checking against CMSG_SPACE), whereas the kernel does not require this, and common userspace code assumes this. * we weren't correctly handling the fact that the SO_TIMESTAMP payload may be larger for the target than the host * we weren't marking the messages with MSG_CTRUNC when we did need to truncate a message that wasn't truncated by the host, but were instead logging a QEMU message; since truncation is always the result of a guest giving us an insufficiently sized buffer, we should report it to the guest as the kernel does and don't log anything * we weren't handling the possibility of the host having a more restrictive alignment requirement for payload structs The major visible issue I wanted to fix is that glibc's "try to talk to nscd" code that it will run on startup will receive a cmsg with a 4 byte payload and only allocates 4 bytes for it, which was causing us to do the wrong thing on architectures that need 8-alignment (we dropped the cmsg and printed a diagnostic message). Peter Maydell (2): linux-user: Fix length handling in host_to_target_cmsg linux-user: use __get_user and __put_user in cmsg conversions linux-user/syscall.c | 89 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 17 deletions(-) -- 1.9.1