From patchwork Thu Sep 22 12:13:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 76752 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp104qgf; Thu, 22 Sep 2016 05:22:20 -0700 (PDT) X-Received: by 10.233.216.194 with SMTP id u185mr1646275qkf.173.1474546940457; Thu, 22 Sep 2016 05:22:20 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x20si946808qtc.65.2016.09.22.05.22.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 22 Sep 2016 05:22:20 -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]:43043 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn319-0005Og-TU for patch@linaro.org; Thu, 22 Sep 2016 08:22:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn2u2-00087S-7v for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:14:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn2tx-0006JS-7M for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:14:57 -0400 Received: from mail-lf0-f43.google.com ([209.85.215.43]:35282) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn2tw-0006It-WD for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:14:53 -0400 Received: by mail-lf0-f43.google.com with SMTP id l131so65690477lfl.2 for ; Thu, 22 Sep 2016 05:14:52 -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=GSUEMaX8+5/eFtvDMBhGD5iTODecxgoNmJ1YqeRLw5Y=; b=LgxW2NRKBpYkQFWxTb7a3KlDJZDF13LwwG98OiiUveL4r3Y5Ihs2/QOpRcyF2CD0AB xfvXsw5EhkF3l1tNLF7CsWsIqSHoKkYalLkVMpvPlJUDFHcAivq7BxRhNSRA1+gaTBkb //dygoDR3LUaZgm3r8AHWag4L1pzvzYV1hHNE= 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=GSUEMaX8+5/eFtvDMBhGD5iTODecxgoNmJ1YqeRLw5Y=; b=SLXsco+HzmAUCdXAuSs0R+IFMYkUJNooBi/W2sqrw8D+WCd8BUxit47ehrro4Jh1gH VGKC410+HpnC/BADJHU1wtcOXILANgPOBF7/v9tHS/WcC/8Goq21c3X0F5RMHLYfl764 r0jyQOhe2dvRLiKUSiVleDPvUHyYpXhrP4TVN4EwBmZBKAHf6/6Kycak38oLwa1iks6d msnCcp9OGDdtd7mPXmS5J8i78Z0s9/U/PKR0hWPQ2byZxuUnWl0CVVFeU93ACAzY7vbx Kn2NHkE0ms0vexYtpVB2SM/XvIpxHWTiXicZetYU+RH9kT6iUqh8b1dvIwzDh5TFWRvv RLFQ== X-Gm-Message-State: AE9vXwOqCyf1KwmH/BP5su36FSBf8pHkEtqUYvKEirYXh2e6zU0oWnjCE6xM0G1Mj54J+8Yu X-Received: by 10.25.23.222 with SMTP id 91mr769339lfx.182.1474546431932; Thu, 22 Sep 2016 05:13:51 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id u14sm294378lja.11.2016.09.22.05.13.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Sep 2016 05:13:50 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Thu, 22 Sep 2016 15:13:22 +0300 Message-Id: <97b079703350ec0f6625788fb380f1fa14d0e2c4.1474546244.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] [fuzzy] X-Received-From: 209.85.215.43 Subject: [Qemu-devel] [PULL 02/26] linux-user: Fix errno for sendrecvmsg with large iovec length 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 The sendmsg and recvmsg syscalls use a different errno to indicate an overlarge iovec length from readv and writev. Handle this special case in do_sendrcvmsg_locked() to avoid getting the default errno returned by lock_iovec(). Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.1.4 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 71f40e3..9d18326 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3485,6 +3485,15 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp, count = tswapal(msgp->msg_iovlen); target_vec = tswapal(msgp->msg_iov); + + if (count > IOV_MAX) { + /* sendrcvmsg returns a different errno for this condition than + * readv/writev, so we must catch it here before lock_iovec() does. + */ + ret = -TARGET_EMSGSIZE; + goto out2; + } + vec = lock_iovec(send ? VERIFY_READ : VERIFY_WRITE, target_vec, count, send); if (vec == NULL) {