From patchwork Thu Mar 19 09:26:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 184690 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp1724682ile; Thu, 19 Mar 2020 02:29:51 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsk1kTk8ADTZow2pZovavcHwWFJzDESI6Sba1COj/fBBXtUDUlqq6+KTCcGb18WQUsN+NOG X-Received: by 2002:a37:b17:: with SMTP id 23mr2050801qkl.326.1584610191341; Thu, 19 Mar 2020 02:29:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584610191; cv=none; d=google.com; s=arc-20160816; b=q5qd1N5nVFmkFROiAKScj9V+NDUxWdcmYzVe9L5OH4DTUZtCagEtt+PJXJdaO8Dn8x z4oxJuu7II8KKiBmVBsdhprGiko2xTz5l96T7DcVdykTKXO7XsPMaXwZWM4Sy7E62yeS AxXdTGVDlqMJdalSDR2Sxx6Y0AQ0vxql+f26YO9aXotbPEMCq26gRpOmNWlrfmGhXOdy Ici3FMPLTd+cyPqfznoIeHrwCiJO71CYC/1yj1k2O03NbTRxHV4BmasR+CP9b+VtEpaO 7o/JGf3GvZ9fpT6FaxfEMYtfxPbrUKg8vzdf81HoCe+zKj92/Nm686CTpr80Ieh5oFdu UDAA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from; bh=Q3zdwzqEbUj0sEDnLxYF3gBixyA795qVdjxv2jHwAWU=; b=p6ropZ10J0USyh/SjHLl4+p+LEjN30mn4DTFXqw9oBnYhlpKHaOc2jcpCaW+cp53Bk /08o6fFCjTQtiiXf1QoDp92JA4Dw6hjDsHKKODjB+jxvsmA9gZrJN7ol6tobCZD/QWuW 6VCzWZI8IhR4wbsa4qZ9c6GZLbt+UNuh8jGmuvTxXf3thvUzMdvKzlNGIQHWAnayIT2K UEt2TXPSpcFpd/8nUJeOMGLh9HJSDCRJLqR0OH7SRZNh/WwSV3Z+ZEIZtVGWOp4Jn85f E2WFyyaUc9OgFLu8C1twhG2G9X97358RVPY3nowPgBJQGQTtpYTiCjn+QXclCncjv1i5 7teA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p58si857696qtk.18.2020.03.19.02.29.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Mar 2020 02:29:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:35278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jErUs-0003m8-T8 for patch@linaro.org; Thu, 19 Mar 2020 05:29:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40875) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jErRv-0005MQ-MY for qemu-devel@nongnu.org; Thu, 19 Mar 2020 05:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jErRu-0004D2-Gj for qemu-devel@nongnu.org; Thu, 19 Mar 2020 05:26:47 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:40723) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jErRu-0004Ce-7I for qemu-devel@nongnu.org; Thu, 19 Mar 2020 05:26:46 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mw9oq-1jXlmB0qrU-00s8TV; Thu, 19 Mar 2020 10:26:35 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v3 05/16] linux-user: Flush out implementation of gettimeofday Date: Thu, 19 Mar 2020 10:26:16 +0100 Message-Id: <20200319092627.51487-6-laurent@vivier.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200319092627.51487-1-laurent@vivier.eu> References: <20200319092627.51487-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:A1gRnY8zWnzS4FbXY6sw/gIdS9rOUf6PKVl0Fh7zabe1Ojordm3 j5Gv34XV1xEmN61PjkE9sUVX8be70NciUyXyGotX6s1PoGezB9kfMmIuYKO4kcJcjC93ABb GNd7QHnldbAve6Zg36G7ZJqMhaBFy6A+QGDBR5D9CqnxPGKRsxTMBXnh7xspkh/aZjpHgyG ozv8bXJw4Tg+7S/FFOMAQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:eDuNZpO6p+w=:BkUi6WE3VEQf4xndonIecB 6XV0ZGNdHbWo1ocLy3J7d3hqL7h2UOQc7zLv4YP6i7XprYj+vKPSsYw93ORm+8WsmQIbNtT16 P+TTaVrO8a2Ojfy7Qh8VSKD/T/ROvb5K+CCRm4iX9ASuidnx9dC1DQdzS2V+VcgSwHVl+QJ82 wefAwIif8qHNerL2JRkck24XBmMjOVi0JO7UDom9W/XzzlWOamDeNI/CiP3y5zWWXDi2hKX4n hcj3H+DOB7E+JvcpxcYZU5aqRIDI6cl0LCYAU1YI+xMXLZmxmuwFpPSAiYcHp4RhUv/tPd+Qi Inf9B5Z82SkgSGr77+1sgp+qL8l//JyFB7c/K33RUuwZW3HNYjcOzW0Tpc4XzaHb4Mh2Jr8v5 TEp6I9/L2gG5QDI97ERhlkjy0AYvYYcwzokM34UqFHImRVbxjD3gg7VMlHKCu1LI5mGQoU6h6 DdVFC9OeMNKm8LhwqcAa1lQ1d90/GgwdiI5ZSSAepc2enkQxztB2uhD4umszWDYFQwxPdIdQO 3A4uK62KQ2YlcAdSVBfWFf545hm9ccqsQrKXp8b9CTW1iu6MJmogDKDy74aYqNyS2qfsE6I6B H8NmBIgazIMDgy8w5H69huIHUraBaAY05sCg/QTeApH7xKC+LvPu7Dh/qPG5cb0wO/AOeSDvS BAt1kLV87z+wENJgSmw85tlWCDuG64WmIzXgXlLkHfRsdXRZk7Oyc8+6ohZ8m42x71JWByRzD QKBBHdA9GrEccxXbJpW4FPO9mTR8K1JeUWVKs6WoQhtTomVcScFZlNWIwD9YPMirun3nDF9aR JO1ZaVN/7q3loOZ2ha8CREiFYWbuYnohsv66v3FAHchCDrmIgkVprr85qikrxouWhMKgP7J X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.135 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Riku Voipio , Richard Henderson , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The first argument, timeval, is allowed to be NULL. The second argument, timezone, was missing. While its use is deprecated, it is still present in the syscall. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20200213032223.14643-6-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5479d67a10be..811495c3a0bc 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1228,6 +1228,23 @@ static inline abi_long host_to_target_timespec64(abi_ulong target_addr, return 0; } +static inline abi_long copy_to_user_timezone(abi_ulong target_tz_addr, + struct timezone *tz) +{ + struct target_timezone *target_tz; + + if (!lock_user_struct(VERIFY_WRITE, target_tz, target_tz_addr, 1)) { + return -TARGET_EFAULT; + } + + __put_user(tz->tz_minuteswest, &target_tz->tz_minuteswest); + __put_user(tz->tz_dsttime, &target_tz->tz_dsttime); + + unlock_user_struct(target_tz, target_tz_addr, 1); + + return 0; +} + static inline abi_long copy_from_user_timezone(struct timezone *tz, abi_ulong target_tz_addr) { @@ -8642,10 +8659,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_NR_gettimeofday: { struct timeval tv; - ret = get_errno(gettimeofday(&tv, NULL)); + struct timezone tz; + + ret = get_errno(gettimeofday(&tv, &tz)); if (!is_error(ret)) { - if (copy_to_user_timeval(arg1, &tv)) + if (arg1 && copy_to_user_timeval(arg1, &tv)) { return -TARGET_EFAULT; + } + if (arg2 && copy_to_user_timezone(arg2, &tz)) { + return -TARGET_EFAULT; + } } } return ret;