qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: fix host_to_target_cmsg in case of multiple headers
@ 2015-08-27 14:50 Jonathan Neuschäfer
  2015-08-27 18:06 ` Peter Maydell
  0 siblings, 1 reply; 15+ messages in thread
From: Jonathan Neuschäfer @ 2015-08-27 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio

In the current implementation, __target_cmsg_nxthdr compares a pointer
derived from target_cmsg against the msg_control field of target_msgh
(through subtraction).  This failed for me when emulating i386 code
under x86_64, because pointers in the host address space and pointers in
the guest address space were not the same.  This patch adds a g2h()
address translation around the msg_control value.

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
 linux-user/syscall_defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index edd5f3c..1eaaf2a 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -248,7 +248,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 *)(__ptr+1) - (char *)g2h(tswapal(__mhdr->msg_control)))
       > tswapal(__mhdr->msg_controllen))
     /* No more entries.  */
     return (struct target_cmsghdr *)0;
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-09-28 22:07 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-27 14:50 [Qemu-devel] [PATCH] linux-user: fix host_to_target_cmsg in case of multiple headers Jonathan Neuschäfer
2015-08-27 18:06 ` Peter Maydell
2015-08-29 16:04   ` Jonathan Neuschäfer
2015-08-29 16:35     ` Peter Maydell
2015-08-31 19:27     ` [Qemu-devel] [PATCH] linux-user: fix cmsg conversion " Jonathan Neuschäfer
2015-09-01 15:45       ` Peter Maydell
2015-09-02  3:12         ` Jonathan Neuschäfer
2015-09-03  5:27         ` Jonathan Neuschäfer
2015-09-04 12:48           ` Peter Maydell
2015-09-21  5:34             ` Jonathan Neuschäfer
2015-09-21 13:13               ` Peter Maydell
2015-09-21 19:45                 ` Riku Voipio
2015-09-21 19:50                   ` Jonathan Neuschäfer
2015-09-28 13:38           ` Riku Voipio
2015-09-28 22:07             ` Jonathan Neuschäfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).