From patchwork Wed May 25 10:31:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9135119 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 70A5D607D9 for ; Wed, 25 May 2016 10:44:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65FC7281E3 for ; Wed, 25 May 2016 10:44:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AB6A27E72; Wed, 25 May 2016 10:44:57 +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 EEB0D27E72 for ; Wed, 25 May 2016 10:44:56 +0000 (UTC) Received: from localhost ([::1]:58860 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WJ6-0003vV-35 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 May 2016 06:44:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41650) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W7G-0001Jv-8c for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5W74-0003Ff-Rl for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:41 -0400 Received: from mail-lf0-x22a.google.com ([2a00:1450:4010:c07::22a]:34618) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W74-0003Er-1V for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:30 -0400 Received: by mail-lf0-x22a.google.com with SMTP id k98so16330355lfi.1 for ; Wed, 25 May 2016 03:32:29 -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=qI05EQ3t9WqQIBbuAAqt/UHefd1X5peCYNowuZomlwc=; b=ihlrvc8rV8YpJRVXWzAQX+jPFkydjisFt1tAvZqHfbyRhq/hveEr2j59s3R9k2Ba/o zDVM63eH9O0TD1cr6g5Rp1/eVxrXsO0pbO4wTkC1/giXhWj9iAn7hIvfCAMgPMHbdlCC RI0bTcerg2jSCi0eIS6JV3nnb+nnv+dHmD+RU= 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=qI05EQ3t9WqQIBbuAAqt/UHefd1X5peCYNowuZomlwc=; b=R+dOZKX/ouK2NJj+NNuBhx+4EBgO2UYZfOzQRuLuCkTKU3l/dzeGXbQCKOKV6SW83n CgesMe3PBt5YoAZDMK8tOC/FVxV7MkrfpkC5dCBI0etiA+9TexHFriIrk7z4MxOxQpXL PnSnOeuDjkYoXA3HIa3m5OJHCnxbAsMIqG+Y4LZjO5uycL5LUN/TenzHIUr8ZT1XJ1Pi M58fpN/fvQc+SCQsco+ECNWdMpWieOoOKakkQo08+0zyK09gahR2o8hoghsv+hHDEHHB x+Wm1Kjcqv80FJESG1KXHvKeczx8PRCX1sf5+DLpeXcz6V9y9EQiMMpGbTjX2nt2K/oA f8lQ== X-Gm-Message-State: ALyK8tIHzJkezvKpKA92UoC7rvuVPh5QRmXMRJua3f9YV21v4x7KzGH7+yqfekEQLXigpDRA X-Received: by 10.25.208.137 with SMTP id h131mr724163lfg.215.1464172349315; Wed, 25 May 2016 03:32:29 -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.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 May 2016 03:32:28 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 13:31:55 +0300 Message-Id: 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:c07::22a Subject: [Qemu-devel] [PULL 23/38] linux-user: Use safe_syscall for read and write 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 Restart read() and write() if signals occur before, or during with SA_RESTART Signed-off-by: Timothy Edward Baldwin Message-id: 1441497448-32489-15-git-send-email-T.E.Baldwin99@members.leeds.ac.uk [PMM: Update to new safe_syscall() convention of setting errno] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b6a8ed6..bee1360 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -707,6 +707,9 @@ static type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ return safe_syscall(__NR_##name, arg1, arg2, arg3, arg4, arg5, arg6); \ } +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) + static inline int host_to_target_sock_type(int host_type) { int target_type; @@ -5983,7 +5986,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, else { if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; - ret = get_errno(read(arg1, p, arg3)); + ret = get_errno(safe_read(arg1, p, arg3)); if (ret >= 0 && fd_trans_host_to_target_data(arg1)) { ret = fd_trans_host_to_target_data(arg1)(p, ret); @@ -5994,7 +5997,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_write: if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; - ret = get_errno(write(arg1, p, arg3)); + ret = get_errno(safe_write(arg1, p, arg3)); unlock_user(p, arg2, 0); break; #ifdef TARGET_NR_open