summaryrefslogtreecommitdiffstats
path: root/linux-user/syscall.c
diff options
context:
space:
mode:
authorPeter Maydell2016-07-15 15:57:27 +0200
committerRiku Voipio2016-09-21 13:20:31 +0200
commit97b079703350ec0f6625788fb380f1fa14d0e2c4 (patch)
treea7bd4f96936f42c0c5a606cb16d6a6fbc9a2377b /linux-user/syscall.c
parentlinux-user: Fix handling of iovec counts (diff)
downloadqemu-97b079703350ec0f6625788fb380f1fa14d0e2c4.tar.gz
qemu-97b079703350ec0f6625788fb380f1fa14d0e2c4.tar.xz
qemu-97b079703350ec0f6625788fb380f1fa14d0e2c4.zip
linux-user: Fix errno for sendrecvmsg with large iovec length
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 <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r--linux-user/syscall.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 71f40e3ab8..9d18326467 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) {