Received: from eggs.gnu.org ([2001:4830:134:3::10]:36721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UvGUF-0001Kf-Vg for qemu-devel@nongnu.org; Fri, 05 Jul 2013 20:36:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UvGUC-0002rS-FT for qemu-devel@nongnu.org; Fri, 05 Jul 2013 20:36:27 -0400 Received: from cantor2.suse.de ([195.135.220.15]:42303 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UvGUC-0002ql-9P for qemu-devel@nongnu.org; Fri, 05 Jul 2013 20:36:24 -0400 From: Alexander Graf Date: Sat, 6 Jul 2013 02:36:13 +0200 Message-Id: <1373070978-11966-5-git-send-email-agraf@suse.de> In-Reply-To: <1373070978-11966-1-git-send-email-agraf@suse.de> References: <1373070978-11966-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PATCH 4/9] linux-user: Fix sendrecvmsg() with QEMU_GUEST_BASE List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Riku Voipio While looking for cmsg entries, we want to compare guest pointers to see whether we're at the end of the passed in array. However, what we really do is we compare our in-use host pointer with the to-be-the-end guest pointer. This comparison is obviously bogus. Change the comparison to compare guest pointer with guest pointer. Signed-off-by: Alexander Graf --- linux-user/syscall_defs.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 92c01a9..8b06a19 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -214,7 +214,7 @@ __target_cmsg_nxthdr (struct target_msghdr *__mhdr, struct target_cmsghdr *__cms __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len))); - if ((unsigned long)((char *)(__ptr+1) - (char *)(size_t)tswapal(__mhdr->msg_control)) + if ((unsigned long)((char *)(h2g(__ptr+1)) - (char *)(size_t)tswapal(__mhdr->msg_control)) > tswapal(__mhdr->msg_controllen)) /* No more entries. */ return (struct target_cmsghdr *)0; -- 1.6.0.2