From patchwork Fri Jul 15 13:57:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9232145 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 904BA60865 for ; Fri, 15 Jul 2016 14:24:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8237C1FF8F for ; Fri, 15 Jul 2016 14:24:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7680A27F86; Fri, 15 Jul 2016 14:24:44 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 032D11FF8F for ; Fri, 15 Jul 2016 14:24:43 +0000 (UTC) Received: from localhost ([::1]:32849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bO42k-0005o8-DV for patchwork-qemu-devel@patchwork.kernel.org; Fri, 15 Jul 2016 10:24:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bO42P-0005n7-Ra for qemu-devel@nongnu.org; Fri, 15 Jul 2016 10:24:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bO42O-0005Sx-Tf for qemu-devel@nongnu.org; Fri, 15 Jul 2016 10:24:21 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:58310) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bO42O-0005Sm-Mu for qemu-devel@nongnu.org; Fri, 15 Jul 2016 10:24:20 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1bO3cQ-0000sE-Cz; Fri, 15 Jul 2016 14:57:30 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 15 Jul 2016 14:57:27 +0100 Message-Id: <1468591048-30230-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468591048-30230-1-git-send-email-peter.maydell@linaro.org> References: <1468591048-30230-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH 2/3] 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: Riku Voipio , patches@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- linux-user/syscall.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8d36d6c..a21ee59 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2985,6 +2985,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) {