From patchwork Fri May 27 13:00:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 627144 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 3rGRfD2c3Lz9sDD for ; Fri, 27 May 2016 23:28:04 +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=RZzpNT73; dkim-atps=neutral Received: from localhost ([::1]:45825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6Ho2-0000Fx-4V for incoming@patchwork.ozlabs.org; Fri, 27 May 2016 09:28:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HNw-0007cU-Ss for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6HNu-0001GQ-Lk for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:03 -0400 Received: from mail-lf0-x229.google.com ([2a00:1450:4010:c07::229]:33331) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HNu-0001GC-E6 for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:02 -0400 Received: by mail-lf0-x229.google.com with SMTP id s64so21623012lfe.0 for ; Fri, 27 May 2016 06:01:02 -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=RZzpNT7366eVQBPoCCUj+Tz68ebanElPb2TkrLTpbOOXaUFK/DTJ2O0+5qvKN6WpEF 5wZdpve54tNFJOGeq/gAPwXGierBc8jfJShgxDQ9FLbTiunpQ7lo/KI6bQWBoqn+4Gqk C2aU3hbmt43OQtxpMfZJHlXlV6nU68V4S3y4M= 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=Kl6CbrZXwo00VbiQG0pA7CJfrlD/07xguGZDJP5oHbSbmJeliGAZeGB/75byBGpj8k T5Zv5uM3jOp+R/QcSGN1dEWbPgbgCm+Wi7klQasw4zIw3mQwHfzsq2483Q2FErFGclPH W1RalO5CiRaUZYSPa5YRqgyNOgzOmmocHRPslP5XjbD/P+/hNu7kdK8IrAFnulqm8hSc 7oQec0KOcxnfraFn2bR0r/oJITmiao6uF9O9KTSvVVbZ9hAi49uf3SYqGpOS5yvdJG+n c/JqOleCyLqYern4BwcdQdtxphJX/XkebD4cVWfOzPMbOsGAFKxJTelsmjB42z6RGTQC YSow== X-Gm-Message-State: ALyK8tL1EOmihAbltkdqrsvWY/GCq2ySzZUZ9SPPbo8dCgwTkJEAD8u5ZqHgAk9mBLkENgAF X-Received: by 10.25.158.73 with SMTP id h70mr3903185lfe.41.1464354061547; Fri, 27 May 2016 06:01:01 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 May 2016 06:01:00 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 16:00:14 +0300 Message-Id: <50afd02b841cf0ccbc988a0fa868bbc4ca67c09e.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:c07::229 Subject: [Qemu-devel] [PULL v2 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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