From patchwork Wed May 25 10:31:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9135161 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 690E16075C for ; Wed, 25 May 2016 11:03:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A53A252D5 for ; Wed, 25 May 2016 11:03:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B73B282A2; Wed, 25 May 2016 11:03:09 +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 3EA91252D5 for ; Wed, 25 May 2016 11:03:07 +0000 (UTC) Received: from localhost ([::1]:58952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Wag-0003kI-7L for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 May 2016 07:03:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W7H-0001Lh-W6 for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5W75-0003Fx-J4 for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:42 -0400 Received: from mail-lf0-x233.google.com ([2a00:1450:4010:c07::233]:36161) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W75-0003Fn-Bu for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:31 -0400 Received: by mail-lf0-x233.google.com with SMTP id e130so16304370lfe.3 for ; Wed, 25 May 2016 03:32:31 -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=CrYKbhQHprqaLXAzqwlfW9pziW4dGgsQrO3Am8ixgTki0ymOMy282rSWSObmA7fOws ZzdGXJ9KIpSR0FDkuV6PBGLek8etxzzkmQbaND66R7fWuAx+ybLNBZK18hiQIre1nuEH AU2aIsx43gixE6ZISxaGwX3hbgPnRLWc7ig2s= 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=cQ/415QicDN6l8NhMujn+Dvza617S2wsegOTpIx59gJrP51qn7Kbbpvq5enlxeAYmy lW4k8je+DTcE/NNqbl3gnpcGFdD12gE1VhKPGCH2nymQNCqYVfuAR/xsR+JB9vkdnjV3 m6RXsRKE2xBR88cHttPLzBEKMNjV81W/x7ME9Q0KurxwN6oOOmF2/5uKgV7hEyPptcz5 0WSLQIumL7J/kGg3VOq2kNUQ6OgmuhLbnd5K2ISnuzzuDrKZH4CJ6bgA5tvvlHiFVmNv 3opKCXvISTm8Ty3w1OR1WEcSdLIxFZSfd10SOYj7JNBLf68yEUzPyaZs92ruGVFjkwZ4 tU8Q== X-Gm-Message-State: ALyK8tLyPh/gqDVmUfMSmnvtevqSQPTLyYpODLNSglgv2/pMKQ6ttHm7CEx9dy1Ncp6b6c6T X-Received: by 10.25.144.68 with SMTP id s65mr585683lfd.214.1464172350648; Wed, 25 May 2016 03:32:30 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 May 2016 03:32:29 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 13:31:56 +0300 Message-Id: <6968c624d26b0ba0cd20e8c16c846b1c940efe93.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:c07::233 Subject: [Qemu-devel] [PULL 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