From patchwork Fri May 27 13:00:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9138365 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 C883060467 for ; Fri, 27 May 2016 13:31:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA79E27CB1 for ; Fri, 27 May 2016 13:31:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF21A28159; Fri, 27 May 2016 13:31:33 +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 7AE1C27CB1 for ; Fri, 27 May 2016 13:31:32 +0000 (UTC) Received: from localhost ([::1]:45838 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HrP-0003N5-H5 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 May 2016 09:31:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HNy-0007eJ-Nk for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6HNw-0001Gu-Ng for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:05 -0400 Received: from mail-lf0-x22e.google.com ([2a00:1450:4010:c07::22e]:36694) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HNv-0001Gd-Tt for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:04 -0400 Received: by mail-lf0-x22e.google.com with SMTP id b73so23107501lfb.3 for ; Fri, 27 May 2016 06:01:03 -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=QFyklf6KJiR9W9VbOMsI7Ijy4DGsgPaPfFupcpfjWcE=; b=A7d0STtAm+Gq8JBkfZfE2WTC9Ud9yNSQFv5BMrZj0j+UYwGvhZsToA80ryJx30cCQj /i2cQVbKVKu8iR25cHPnsBcrYraI0ZwYxC1yAG2blWo/k3MayDhR6zkmYbl90IVjg8It fbeRZgwwSHFgqjcpIVBjWmkJu/Zio28zALLeQ= 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=QFyklf6KJiR9W9VbOMsI7Ijy4DGsgPaPfFupcpfjWcE=; b=MS9d6mZCtUMq5MKkHyRGm+Qnpx7B6aBi3zvKLBZVUW9kvk19iTqw+yx/9fK6pnsWyM JoskeFuOYfqHQpzLOM088QXw+B9+qGJyM5dYCgazjqCNRe3BzQV82eqw9VQDQUkFb+aC VRFwuChgXLawtyz+34u+ws08YCwqz0p348pHEbtOEvUSBkzZoLl2raMOkZ1+AwOKBqLJ mZza3H3F7qJyShTTujCANpHcXrWeSRHH2wfOL8UUj7G+nd0FhgpSqIU421cvT/Mx6NzN FheoErDWnYwFABxoaYjOtjiUNzzmerlQpzBs8hkXlG6TRZx1lkPmzgM2aL2uLrkLKwbV /1fQ== X-Gm-Message-State: ALyK8tJkN0bbL7F5VJbpRlHLBMIrm4V8i5p8T7zgP8YRLS+hbQZEosNQI8oV2qbB0t/73f7/ X-Received: by 10.25.32.193 with SMTP id g184mr4641506lfg.184.1464354063078; Fri, 27 May 2016 06:01:03 -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.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 May 2016 06:01:01 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 16:00:15 +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::22e Subject: [Qemu-devel] [PULL v2 24/38] linux-user: Use safe_syscall for open and openat 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 open() and openat() if signals occur before, or during with SA_RESTART. Signed-off-by: Timothy Edward Baldwin Message-id: 1441497448-32489-17-git-send-email-T.E.Baldwin99@members.leeds.ac.uk [PMM: Adjusted to follow new -1-and-set-errno safe_syscall convention] Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bee1360..0037ee7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -359,18 +359,6 @@ static int sys_getcwd1(char *buf, size_t size) return strlen(buf)+1; } -static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode) -{ - /* - * open(2) has extra parameter 'mode' when called with - * flag O_CREAT. - */ - if ((flags & O_CREAT) != 0) { - return (openat(dirfd, pathname, flags, mode)); - } - return (openat(dirfd, pathname, flags)); -} - #ifdef TARGET_NR_utimensat #ifdef CONFIG_UTIMENSAT static int sys_utimensat(int dirfd, const char *pathname, @@ -709,6 +697,8 @@ static type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 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) static inline int host_to_target_sock_type(int host_type) { @@ -5851,7 +5841,7 @@ static int do_openat(void *cpu_env, int dirfd, const char *pathname, int flags, if (is_proc_myself(pathname, "exe")) { int execfd = qemu_getauxval(AT_EXECFD); - return execfd ? execfd : sys_openat(dirfd, exec_path, flags, mode); + return execfd ? execfd : safe_openat(dirfd, exec_path, flags, mode); } for (fake_open = fakes; fake_open->filename; fake_open++) { @@ -5887,7 +5877,7 @@ static int do_openat(void *cpu_env, int dirfd, const char *pathname, int flags, return fd; } - return sys_openat(dirfd, path(pathname), flags, mode); + return safe_openat(dirfd, path(pathname), flags, mode); } #define TIMER_MAGIC 0x0caf0000