From patchwork Wed Jun 8 13:30:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9164779 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 15744604DB for ; Wed, 8 Jun 2016 14:07:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05BE428355 for ; Wed, 8 Jun 2016 14:07:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 044D328345; Wed, 8 Jun 2016 14:07: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 4541428366 for ; Wed, 8 Jun 2016 14:07:09 +0000 (UTC) Received: from localhost ([::1]:57213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAe8S-0004Iu-E0 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Jun 2016 10:07:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZq-0004gu-7N for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAdZj-0005sk-PX for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:21 -0400 Received: from mail-lf0-x22f.google.com ([2a00:1450:4010:c07::22f]:34020) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZj-0005sZ-15 for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:15 -0400 Received: by mail-lf0-x22f.google.com with SMTP id s186so5880432lfs.1 for ; Wed, 08 Jun 2016 06:31:14 -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=9AQQPmbJbW4QGutVqfCRZg9L3OJER+IHPtN/IZiJ72o=; b=eHbhNxryMTivYJIUBW/bWhCLwllTuHc5adgM/TJmiPBnrXnC1gkHksoJou2ZLN2Yac kPNDxWk1jGsAZwgsMQExCckkBuvrXj1exPiGjPjtXBwvzpBRnH0ti/g98uDdU4gvBlTG F+vfXlOEbeMQ+KSnGrLQdRxrh1iKY5k7s/jPg= 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=9AQQPmbJbW4QGutVqfCRZg9L3OJER+IHPtN/IZiJ72o=; b=DkT2Z5aiO6vRn2ECagfC+oVfeuApp6lohGMIDpt13OnL5Ilu1Hi8PJmx4iFfY3FZdS U7wrwznSb3tWsNeVI4+n+2iZsMUYP1/A/9Kf9ZTlJR6h2GOWdn3RRVrEFRB0U+PuJnse ose0oio0EEhL0rLInYkNyXAIICfAkkFwQ3wON29shgF2Sze6m1p/kQJ0m7O8ameuFBPE aroHCATZvaW4UIiMJhMYtQyzbr2bG18mYKJxBOYY9b4ZuRVSsIwl+6f7qUXFwNvmMOrv eIxYctS24Nw9gskaIFSY731yvuLQNGVHokokdHmA+WVCZl00FPCgxNtJlxJEpY8fTioA nqjw== X-Gm-Message-State: ALyK8tLt0i3dhSZK6NRAPdIfKHidcSxs9v2c/yUFl/Zkj0ae67L7+srg95LdkAs744n8cyGI X-Received: by 10.25.32.85 with SMTP id g82mr130248lfg.184.1465392674289; Wed, 08 Jun 2016 06:31:14 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id 2sm139854lja.37.2016.06.08.06.31.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jun 2016 06:31:13 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 8 Jun 2016 16:30:20 +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::22f Subject: [Qemu-devel] [PULL 39/44] linux-user: Use safe_syscall wrapper for accept and accept4 syscalls 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: Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Maydell Use the safe_syscall wrapper for the accept and accept4 syscalls. accept4 has been in the kernel since 2.6.28 so we can assume it is always present. Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3ccb367..d414dc4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -721,6 +721,8 @@ safe_syscall3(ssize_t, recvmsg, int, fd, struct msghdr *, msg, int, flags) safe_syscall2(int, flock, int, fd, int, operation) safe_syscall4(int, rt_sigtimedwait, const sigset_t *, these, siginfo_t *, uinfo, const struct timespec *, uts, size_t, sigsetsize) +safe_syscall4(int, accept4, int, fd, struct sockaddr *, addr, socklen_t *, len, + int, flags) safe_syscall2(int, nanosleep, const struct timespec *, req, struct timespec *, rem) #ifdef TARGET_NR_clock_nanosleep @@ -3061,19 +3063,6 @@ static abi_long do_sendrecvmmsg(int fd, abi_ulong target_msgvec, return ret; } -/* If we don't have a system accept4() then just call accept. - * The callsites to do_accept4() will ensure that they don't - * pass a non-zero flags argument in this config. - */ -#ifndef CONFIG_ACCEPT4 -static inline int accept4(int sockfd, struct sockaddr *addr, - socklen_t *addrlen, int flags) -{ - assert(flags == 0); - return accept(sockfd, addr, addrlen); -} -#endif - /* do_accept4() Must return target values and target errnos. */ static abi_long do_accept4(int fd, abi_ulong target_addr, abi_ulong target_addrlen_addr, int flags) @@ -3086,7 +3075,7 @@ static abi_long do_accept4(int fd, abi_ulong target_addr, host_flags = target_to_host_bitmask(flags, fcntl_flags_tbl); if (target_addr == 0) { - return get_errno(accept4(fd, NULL, NULL, host_flags)); + return get_errno(safe_accept4(fd, NULL, NULL, host_flags)); } /* linux returns EINVAL if addrlen pointer is invalid */ @@ -3102,7 +3091,7 @@ static abi_long do_accept4(int fd, abi_ulong target_addr, addr = alloca(addrlen); - ret = get_errno(accept4(fd, addr, &addrlen, host_flags)); + ret = get_errno(safe_accept4(fd, addr, &addrlen, host_flags)); if (!is_error(ret)) { host_to_target_sockaddr(target_addr, addr, addrlen); if (put_user_u32(addrlen, target_addrlen_addr)) @@ -8334,11 +8323,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_accept4 case TARGET_NR_accept4: -#ifdef CONFIG_ACCEPT4 ret = do_accept4(arg1, arg2, arg3, arg4); -#else - goto unimplemented; -#endif break; #endif #ifdef TARGET_NR_bind