qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/3] linux-user: Fix errno for sendrecvmsg with larg


From: Peter Maydell
Subject: [Qemu-devel] [PATCH 2/3] linux-user: Fix errno for sendrecvmsg with large iovec length
Date: Fri, 15 Jul 2016 14:57:27 +0100

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 <address@hidden>
---
 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) {
-- 
1.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]