From patchwork Sun Jun 29 12:14:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 365380 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 08DA8140085 for ; Sun, 29 Jun 2014 22:21:56 +1000 (EST) Received: from localhost ([::1]:57565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1E7G-00086H-7U for incoming@patchwork.ozlabs.org; Sun, 29 Jun 2014 08:21:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1E0g-0004AC-Pw for qemu-devel@nongnu.org; Sun, 29 Jun 2014 08:15:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1E0c-0000lL-Er for qemu-devel@nongnu.org; Sun, 29 Jun 2014 08:15:06 -0400 Received: from afflict.kos.to ([92.243.29.197]:54995) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1E0Y-0000cA-1v for qemu-devel@nongnu.org; Sun, 29 Jun 2014 08:15:02 -0400 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 560D22658A; Sun, 29 Jun 2014 14:14:56 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Sun, 29 Jun 2014 15:14:51 +0300 Message-Id: X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: Peter Maydell , Anthony Liguori , Paul Burton Subject: [Qemu-devel] [PULL v2 11/13] linux-user: allow NULL tv argument for settimeofday X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Paul Burton The tv argument to the settimeofday syscall is allowed to be NULL, if the program only wishes to provide the timezone. QEMU previously returned -EFAULT when tv was NULL. Instead, execute the syscall & provide NULL to the kernel as the target program expected. Signed-off-by: Paul Burton Signed-off-by: Riku Voipio --- linux-user/syscall.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0ce1a4e..8e2762b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6401,11 +6401,15 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; case TARGET_NR_settimeofday: { - struct timeval tv; + struct timeval tv, *ptv = NULL; struct timezone tz, *ptz = NULL; - if (copy_from_user_timeval(&tv, arg1)) - goto efault; + if (arg1) { + if (copy_from_user_timeval(&tv, arg1)) { + goto efault; + } + ptv = &tv; + } if (arg2) { if (copy_from_user_timezone(&tz, arg2)) { @@ -6414,7 +6418,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ptz = &tz; } - ret = get_errno(settimeofday(&tv, ptz)); + ret = get_errno(settimeofday(ptv, ptz)); } break; #if defined(TARGET_NR_select)