From patchwork Wed Jun 8 13:30:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 69657 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2517647qgf; Wed, 8 Jun 2016 07:11:21 -0700 (PDT) X-Received: by 10.55.165.69 with SMTP id o66mr4908480qke.153.1465395081578; Wed, 08 Jun 2016 07:11:21 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o108si755409qge.110.2016.06.08.07.11.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 Jun 2016 07:11:21 -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]:57233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAeCX-0007mV-1W for patch@linaro.org; Wed, 08 Jun 2016 10:11:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZf-0004Xi-Mc for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAdZZ-0005pp-9p for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:10 -0400 Received: from mail-lf0-x231.google.com ([2a00:1450:4010:c07::231]:33727) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZY-0005pc-5v for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:05 -0400 Received: by mail-lf0-x231.google.com with SMTP id s64so5907067lfe.0 for ; Wed, 08 Jun 2016 06:31:04 -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=LXHRnIxyJrBUW8w435wrM9YFmjoRS3B/A46Wr2hX1RE=; b=SPyvWNIgFWWX6i55BB9BpYb2NvhC9f1if0QbzOnc1a5X/SoJT0yjaGnPUiNL4Fcc67 YLIqbNH5jClBEptX6Hq4CxmbmeNj0sFORlogSrAZ8tkg8yT1vAwWogN2sn7wT24mzv66 j/BdXcID8Y15XDV6xg8JXBdaFA84xghMsjI10= 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=LXHRnIxyJrBUW8w435wrM9YFmjoRS3B/A46Wr2hX1RE=; b=iNlm9L5R37fm/bXp3lIba3YfMXy7VBEMO5pvuyNNlvYSZerWz2BrCgD2SGl/CyyVV8 S9D92MvFeRQQSkVyarP/IcDeQfwgV1Q5jbqzhzZ0TZtYh+byxvUMH6nABKy5IENn65Ar 2eDNARIxseSl0amhtgjld+ZfKDrVG2/7C9asNMdljkN3iXO/mAf4WqJR0Oer8Mmp734h OB4fW2JCRpchs9UVGuh4Zs1+JFtwTIDNVZUf0Dchey7AfmhjU2JgRMGxFLe0rfAoWkaJ 6wkQeZe2/pCV4z+m+0+KKZBqQN6u3IAfTWn+sbh3qkFyBotwLaZEVmf0EQ9wE1hscNHw qs1A== X-Gm-Message-State: ALyK8tKCIEPT3XGT6OsPExPn4LSpsUrp8zG2kW1kitA1v/8vbnPA8Tt5ks2Pw3W1MzQ4Jn3N X-Received: by 10.25.166.71 with SMTP id p68mr4871940lfe.48.1465392663443; Wed, 08 Jun 2016 06:31:03 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jun 2016 06:31:02 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 8 Jun 2016 16:30:11 +0300 Message-Id: <666875306e03e1f94e1d4c808502585c10abc69a.1465392531.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::231 Subject: [Qemu-devel] [PULL 30/44] linux-user: Use safe_syscall wrapper for send* and recv* 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 send, sendto, sendmsg, recv, recvfrom and recvmsg syscalls. RV: adjusted to apply Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) -- 2.1.4 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b363944..bcae62d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -716,6 +716,12 @@ safe_syscall3(ssize_t, readv, int, fd, const struct iovec *, iov, int, iovcnt) safe_syscall3(ssize_t, writev, int, fd, const struct iovec *, iov, int, iovcnt) safe_syscall3(int, connect, int, fd, const struct sockaddr *, addr, socklen_t, addrlen) +safe_syscall6(ssize_t, sendto, int, fd, const void *, buf, size_t, len, + int, flags, const struct sockaddr *, addr, socklen_t, addrlen) +safe_syscall6(ssize_t, recvfrom, int, fd, void *, buf, size_t, len, + int, flags, struct sockaddr *, addr, socklen_t *, addrlen) +safe_syscall3(ssize_t, sendmsg, int, fd, const struct msghdr *, msg, int, flags) +safe_syscall3(ssize_t, recvmsg, int, fd, struct msghdr *, msg, int, flags) static inline int host_to_target_sock_type(int host_type) { @@ -2910,10 +2916,10 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp, ret = target_to_host_cmsg(&msg, msgp); } if (ret == 0) { - ret = get_errno(sendmsg(fd, &msg, flags)); + ret = get_errno(safe_sendmsg(fd, &msg, flags)); } } else { - ret = get_errno(recvmsg(fd, &msg, flags)); + ret = get_errno(safe_recvmsg(fd, &msg, flags)); if (!is_error(ret)) { len = ret; if (fd_trans_host_to_target_data(fd)) { @@ -3162,9 +3168,9 @@ static abi_long do_sendto(int fd, abi_ulong msg, size_t len, int flags, unlock_user(host_msg, msg, 0); return ret; } - ret = get_errno(sendto(fd, host_msg, len, flags, addr, addrlen)); + ret = get_errno(safe_sendto(fd, host_msg, len, flags, addr, addrlen)); } else { - ret = get_errno(send(fd, host_msg, len, flags)); + ret = get_errno(safe_sendto(fd, host_msg, len, flags, NULL, 0)); } unlock_user(host_msg, msg, 0); return ret; @@ -3193,10 +3199,11 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, size_t len, int flags, goto fail; } addr = alloca(addrlen); - ret = get_errno(recvfrom(fd, host_msg, len, flags, addr, &addrlen)); + ret = get_errno(safe_recvfrom(fd, host_msg, len, flags, + addr, &addrlen)); } else { addr = NULL; /* To keep compiler quiet. */ - ret = get_errno(qemu_recv(fd, host_msg, len, flags)); + ret = get_errno(safe_recvfrom(fd, host_msg, len, flags, NULL, 0)); } if (!is_error(ret)) { if (target_addr) {