Skip to content

Commit

Permalink
linux-user: Fix errno for sendrecvmsg with large iovec length
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
pm215 authored and Riku Voipio committed Sep 21, 2016
1 parent dab32b3 commit 97b0797
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions linux-user/syscall.c
Expand Up @@ -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) {
Expand Down

0 comments on commit 97b0797

Please sign in to comment.