qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: Riku Voipio <riku.voipio@iki.fi>,
	Laurent Vivier <laurent@vivier.eu>,
	Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PULL 04/13] linux-user: Fix payload size logic in host_to_target_cmsg()
Date: Fri, 25 May 2018 10:17:45 +0200	[thread overview]
Message-ID: <20180525081754.29506-5-laurent@vivier.eu> (raw)
In-Reply-To: <20180525081754.29506-1-laurent@vivier.eu>

From: Peter Maydell <peter.maydell@linaro.org>

Coverity points out that there's a missing break in the switch in
host_to_target_cmsg() where we update tgt_len for
cmsg_level/cmsg_type combinations which require a different length
for host and target (CID 1385425).  To avoid duplicating the default
case (target length same as host) in both switches, set that before
the switch so that only the cases which want to override it need any
code.

This fixes a bug where we would have used the wrong length
for SOL_SOCKET/SO_TIMESTAMP messages where the target and
host have differently sized 'struct timeval' (ie one is 32
bit and the other is 64 bit).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20180518184715.29833-1-peter.maydell@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/syscall.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index dd77f86ea2..d02c16bbc6 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1848,6 +1848,7 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
         /* Payload types which need a different size of payload on
          * the target must adjust tgt_len here.
          */
+        tgt_len = len;
         switch (cmsg->cmsg_level) {
         case SOL_SOCKET:
             switch (cmsg->cmsg_type) {
@@ -1857,8 +1858,8 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
             default:
                 break;
             }
+            break;
         default:
-            tgt_len = len;
             break;
         }
 
-- 
2.14.3

  parent reply	other threads:[~2018-05-25  8:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-25  8:17 [Qemu-devel] [PULL 00/13] Linux user for 2.13 patches Laurent Vivier
2018-05-25  8:17 ` [Qemu-devel] [PULL 01/13] linux-user: Assert on bad type in thunk_type_align() and thunk_type_size() Laurent Vivier
2018-05-25  8:17 ` [Qemu-devel] [PULL 02/13] linux-user: update netlink emulation Laurent Vivier
2018-05-25  8:17 ` [Qemu-devel] [PULL 03/13] linux-user: update comments to point to tcg_exec_init() Laurent Vivier
2018-05-25  8:17 ` Laurent Vivier [this message]
2018-05-25  8:17 ` [Qemu-devel] [PULL 05/13] linux-user: move mips socket.h definitions to mips/sockbits.h Laurent Vivier
2018-05-25  8:17 ` [Qemu-devel] [PULL 06/13] linux-user: move alpha socket.h definitions to alpha/sockbits.h Laurent Vivier
2018-05-25  8:17 ` [Qemu-devel] [PULL 07/13] linux-user: move sparc/sparc64 socket.h definitions to sparc/sockbits.h Laurent Vivier
2018-05-25  8:17 ` [Qemu-devel] [PULL 08/13] linux-user: move socket.h generic definitions to generic/sockbits.h Laurent Vivier
2018-05-25  8:17 ` [Qemu-devel] [PULL 09/13] linux-user: move ppc socket.h definitions to ppc/sockbits.h Laurent Vivier
2018-05-25  8:17 ` [Qemu-devel] [PULL 10/13] linux-user: update ARCH_HAS_SOCKET_TYPES use Laurent Vivier
2018-05-25  8:17 ` [Qemu-devel] [PULL 11/13] linux-user: copy sparc/sockbits.h definitions from linux Laurent Vivier
2018-05-25  8:17 ` [Qemu-devel] [PULL 12/13] linux-user: define TARGET_SO_REUSEPORT Laurent Vivier
2018-05-25  8:17 ` [Qemu-devel] [PULL 13/13] gdbstub: Clarify what gdb_handlesig() is doing Laurent Vivier
2018-05-25  8:32 ` [Qemu-devel] [PULL 00/13] Linux user for 2.13 patches no-reply
2018-05-25  9:54 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180525081754.29506-5-laurent@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).