From patchwork Wed May 25 10:31:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 626113 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 3rF8Lv2NZcz9sRZ for ; Wed, 25 May 2016 20:55:19 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=hWGdmyXu; dkim-atps=neutral Received: from localhost ([::1]:58912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WT6-0005Si-F3 for incoming@patchwork.ozlabs.org; Wed, 25 May 2016 06:55:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41605) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W7E-0001IA-DM for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5W76-0003H3-M1 for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:39 -0400 Received: from mail-lb0-x233.google.com ([2a00:1450:4010:c04::233]:35905) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W76-0003GH-F7 for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:32 -0400 Received: by mail-lb0-x233.google.com with SMTP id h1so14013352lbj.3 for ; Wed, 25 May 2016 03:32:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2vwisSp07UHRmkE+WjDWK0JvhvDu13D9/PQlmGF2Bc8=; b=hWGdmyXuz4qgVW1/AlLlolrVL8DOuKkVLpy0BnUPgWuWXRMkmLXIFjYJc/fn8VhvIi YKVu/YnVT7NC0wYcHtdKaJglFA5L00R+4wz9KcDxvGg7YqgvWe8E8xjFrK+Sk/V2Ro8x /RgPf0oUDr+SBTLXr8UwdmPLoVr5uIWWbrHi4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2vwisSp07UHRmkE+WjDWK0JvhvDu13D9/PQlmGF2Bc8=; b=EFlEj+YFgGOVIAOIbdorrgW3W4p9Z4jZz/kYg+l8yrABsX9RAYsaMFwCwguUEKauTq sGCcTJqpYcYGPFeETf49kX5QLXQTPMSg1LHPiVHBHuJPFtXjUMcVRczhw0kFXrGBdyM0 T+dCLEc9QJzd0X1ergPUZJaHZPMxVdbQK04Gjj+xc+cKBt17E8DgSkHMgMQhcSEOO0nn vBWv45jS0d1gblfDNqAUn+l8F1xxlZR1/2uxwvAfp9vUkpBJTdbmuaLWMkM/voWUdrlw P5UwMQYHHdJF6B3g6/r67kM/x02nlVvM+RJWwKZf2rw8K+QUcocLrkBfa40nXxDulLKT VWLA== X-Gm-Message-State: ALyK8tLmeFt6Acy4Qe8sIGomCkZRpnIuL+1I+dKwowWeWL2CoLT5tElgyVai8MoeTmwI6KYf X-Received: by 10.112.163.73 with SMTP id yg9mr829249lbb.73.1464172351673; Wed, 25 May 2016 03:32:31 -0700 (PDT) Received: from beaming.home (91-157-168-132.elisa-laajakaista.fi. [91.157.168.132]) by smtp.gmail.com with ESMTPSA id o75sm1379610lfi.9.2016.05.25.03.32.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 May 2016 03:32:30 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 13:31:57 +0300 Message-Id: <559e8fd6a9b5b112739a0328c46e99f8010efbf1.1464153942.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c04::233 Subject: [Qemu-devel] [PULL 25/38] linux-user: Use safe_syscall for wait system calls 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: Timothy E Baldwin Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Timothy E Baldwin Use safe_syscall for waitpid, waitid and wait4 syscalls. Note that this change allows us to implement support for waitid's fifth (rusage) argument in future; for the moment we ignore it as we have done up til now. Signed-off-by: Timothy Edward Baldwin Message-id: 1441497448-32489-18-git-send-email-T.E.Baldwin99@members.leeds.ac.uk [PMM: Adjust to new safe_syscall convention. Add fifth waitid syscall argument (which isn't present in the libc interface but is in the syscall ABI)] Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0037ee7..d9f4695 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -699,6 +699,10 @@ safe_syscall3(ssize_t, read, int, fd, void *, buff, size_t, count) safe_syscall3(ssize_t, write, int, fd, const void *, buff, size_t, count) safe_syscall4(int, openat, int, dirfd, const char *, pathname, \ int, flags, mode_t, mode) +safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, \ + struct rusage *, rusage) +safe_syscall5(int, waitid, idtype_t, idtype, id_t, id, siginfo_t *, infop, \ + int, options, struct rusage *, rusage) static inline int host_to_target_sock_type(int host_type) { @@ -6037,7 +6041,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_waitpid: { int status; - ret = get_errno(waitpid(arg1, &status, arg3)); + ret = get_errno(safe_wait4(arg1, &status, arg3, 0)); if (!is_error(ret) && arg2 && ret && put_user_s32(host_to_target_waitstatus(status), arg2)) goto efault; @@ -6049,7 +6053,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, { siginfo_t info; info.si_pid = 0; - ret = get_errno(waitid(arg1, arg2, &info, arg4)); + ret = get_errno(safe_waitid(arg1, arg2, &info, arg4, NULL)); if (!is_error(ret) && arg3 && info.si_pid != 0) { if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0))) goto efault; @@ -7761,7 +7765,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, rusage_ptr = &rusage; else rusage_ptr = NULL; - ret = get_errno(wait4(arg1, &status, arg3, rusage_ptr)); + ret = get_errno(safe_wait4(arg1, &status, arg3, rusage_ptr)); if (!is_error(ret)) { if (status_ptr && ret) { status = host_to_target_waitstatus(status);