From patchwork Fri May 27 13:00:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9138363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E54C860467 for ; Fri, 27 May 2016 13:30:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE35527CB1 for ; Fri, 27 May 2016 13:30:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B09A828159; Fri, 27 May 2016 13:30:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FSL_HELO_HOME, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1C70A27CB1 for ; Fri, 27 May 2016 13:30:46 +0000 (UTC) Received: from localhost ([::1]:45835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6Hqf-0002aC-Fv for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 May 2016 09:30:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HO3-0007mH-BX for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6HNx-0001H8-Ah for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:11 -0400 Received: from mail-lb0-x22b.google.com ([2a00:1450:4010:c04::22b]:33627) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HNx-0001Gy-2z for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:05 -0400 Received: by mail-lb0-x22b.google.com with SMTP id k7so31697119lbm.0 for ; Fri, 27 May 2016 06:01:04 -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=is2VzFgXFx8Zs394L2iQEz0p7GYdhPDILNCKqvTy6PVZYHEdOwRQgeJgnre+f7d6RH gopiH3fbVyDFDFDLhLFZe8pB2cpu5S0r7oXzIbx65vwbPkrF9uK1DxJmN/tDiPbelhzA yGuVNX4HLpHDY7ZW0tnIqDVBiA4/tvMh8FqhM= 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=YCKLeM8dVGS99IWpze8lBizY+C21pZ2sx8siya/hPOX7Qsmng1tdJTt+AUU7tAikg+ FZJ1s/pY3Vo+PGfEYJn7SnOz3L3I0kMVNQORgneU65p2v1y6/ZZzVGFU2nNnt5XvaOZi zazsQfEGnCS/HIWvVeZd9X9Oa61G2MKCKGC+NUntGIfZG4My22rjD95q7ircYT+vJ9lt i6XS9N4CEMLfrRWdiPvUKZz1Yp2g8WIlNM9a+2XYWz/SlG2j6xtDv/BPFD2tWfvw5CGw VRvRuCMYwfwJXg5jDjAD4VFiIeO1sNPN04a37/EFsm1uPHThLJlh6ohsJzt3zzNvx5Wz g4KQ== X-Gm-Message-State: ALyK8tJadyusQRKpMn3zdccbOZTAjbbgXqaFXw77C2sxLrXnDSUElt+/b6X5NnzA+voslKGP X-Received: by 10.112.201.10 with SMTP id jw10mr4459427lbc.25.1464354064185; Fri, 27 May 2016 06:01:04 -0700 (PDT) Received: from beaming.home (91-157-168-132.elisa-laajakaista.fi. [91.157.168.132]) by smtp.gmail.com with ESMTPSA id n16sm2281066lfg.31.2016.05.27.06.01.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 May 2016 06:01:03 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 16:00:16 +0300 Message-Id: <4af80a3783950380df85ecca78aea3e3bad2e846.1464353863.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::22b Subject: [Qemu-devel] [PULL v2 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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);