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: 69656 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2516117qgf; Wed, 8 Jun 2016 07:08:33 -0700 (PDT) X-Received: by 10.55.39.141 with SMTP id n135mr5044778qkn.149.1465394913827; Wed, 08 Jun 2016 07:08:33 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p100si737295qkh.232.2016.06.08.07.08.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 Jun 2016 07:08:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAe9p-0005DV-Bs for patch@linaro.org; Wed, 08 Jun 2016 10:08:33 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.1.4 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