From patchwork Fri May 25 08:17:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 136793 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3278686lji; Fri, 25 May 2018 01:18:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLFgTQSV5lYTvoItUnzizW42ZaW+DGoTV+3jbkfu4ewF1fD+XquZCbBIirgXycbwfdKijk5 X-Received: by 2002:a37:4041:: with SMTP id n62-v6mr1095466qka.287.1527236334522; Fri, 25 May 2018 01:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527236334; cv=none; d=google.com; s=arc-20160816; b=PY/diNI1Cb2hQc8VfV6nLPQQ9plmLEMAEKI6UV2HFS3N+CdjoMcNqq2LqjiA6169eG 0bilsy3DtyvQDKAVK+YiybBMXpbyuv5yZD98zs3ULrE68Z+9hD7J1Wg0uQRmTyCWjUt1 5PgRhZeMVvK9rC87QzqGpIQo1sMY3EaP5QnAG7gCKXoNBjkm64y6YwRGPQW+yJe/IVU4 9HFFP1bO2WTHtk+D5HRH1PUTu8AdrufC9SVIo7i6heWOpbNX2+Wb3vIHUk/GLWNRTx5t iHzy25079sg+bZVbjX8HKnuF7bDBUKPrrm4IlRfN52dKCdrLvGny3avMm+haTyPJcX0a Y4xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=hUlZFw0Uk9koZGwK4cKkW9wTWvYz1oqRfTV+6DtT4cU=; b=PPG1OG+r1+BVMFml5u71xWQwrOoVBDr8nfp28tD2bW7s8q9utsj/YnFhCEHeF6Pn5M sZql1En3pqJhSANlKKd1UERgKhRgcyKeKwtO5rVA5kn1vraHCqKkHdvlbrMRgBFO+Q58 jrN1/NtZpFogrk7oArJOZON1RK2eSPvekJqG3qqSRHVwZjqaePhvZVOUDpIVw/H7TBkz aVrquWgOWz5PqXnmy1xhFECGE79a1KsgARxOLfuzEkOnczXlu3KtVFE++hGahO2QLgYL 2DjUtl1USd7qansb87p27NK+ezk2n2EsCmLYw5q3g6dewtPPUGaPWmQ8I/6w7Y4ko11I FDgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v21-v6si7160061qtp.332.2018.05.25.01.18.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 25 May 2018 01:18:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:42376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM7w5-0001mj-U2 for patch@linaro.org; Fri, 25 May 2018 04:18:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM7vc-0001kB-ND for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fM7vY-0008FW-DJ for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:24 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:32979) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fM7vY-0008Er-3V for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:20 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.183]) with ESMTPSA (Nemesis) id 0M2MnE-1gBc182MhI-00s9UX; Fri, 25 May 2018 10:18:10 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Fri, 25 May 2018 10:17:45 +0200 Message-Id: <20180525081754.29506-5-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180525081754.29506-1-laurent@vivier.eu> References: <20180525081754.29506-1-laurent@vivier.eu> X-Provags-ID: V03:K1:IbbJw5M6Y1RR3q3Xv7gDeApulJSgTNXh56P6/TcK5QAy6U4wBHl jTrWbwamv4D7w6CjEenGs042j8ZqmLaDFvtIJ22Cj5uXFHa6lzPcjZJDxU90yN5etr/b2Jv Cu0Wf8KK2LEqUDCBiLZlJbiVophutYyKE7J4HCjVq/Q7CVwPJZbmI7MlQ6qGqiYiBFZV/wV AIdGwDAdMZ0PbhrFTD6zw== X-UI-Out-Filterresults: notjunk:1; V01:K0:MNJF2hzXsxs=:EI1vn7HPiAFy3Zoyp22myx f0+Z9ra05qYGpOASqaW1NcZ3jWareF2Qe+o0xrvENYpuLEvkW2AsB7XQ9WtcAQiaJX6Lad5jE WDfrfq8IARwJi1hlBnXnvI42c/BknA0NZzbd7a/50sQTIcW9ssJ0BH2j70AzojJX6lNk5MsZ/ rR8iMbi5BCrhXv3X5OxB68iCEWG8C7RoxmALZuVizSYIGUgmsZnPVAppMvqDCqICWmqlgY/pm 2YyKzDxW/et/JPsyhAue8ceVLs6T2i0qgvDKiPPMRsJoc72AUjme7FkKYxo0IyvxJkQSJwgcG Wr35Oao0EcFGwMi6y3qmX6ha6X7dT1RzCD1cWfEEJ5cN4HNerzPuFL8G2v8eo+55irC6KEt5/ h5sB6ZJGtbzxVSTzziRDU0aidoiJNY67dJsrX/TzRXjRlWNdAMGk9/kEfJeYZpHy6799Jv01+ ocKrIOovX4ScP2aq73as/irk/H/xnOETYGbEzUBFaVu4Z3GXNBniUScuBaEeZPzDvbn4p+DF7 HIZ9b7/Dv6N1gqpietj1iTFvrY+2y6iZahAbe6xEdGQFvRZUIaNyyTfdgA6GrkbeUxg7Ki5st 2BT0t/F7iEXEzR2msIiXBWV5XqqDrRnVo3vr8HWMIXXyvaXaoPOnBUYAyMXfVKesy9VJ5oU8x p2XTCXy+wNsXOkZgckViK2zc2F3ctlWsuvuENTbPZYC3xhLtpAN+lfgGCzNlgrY9n1wE= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.75 Subject: [Qemu-devel] [PULL 04/13] linux-user: Fix payload size logic in host_to_target_cmsg() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell 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 Reviewed-by: Laurent Vivier Message-Id: <20180518184715.29833-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.14.3 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; }