[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 22/22] linux-user: Allow sendmsg() without IOV
From: |
Laurent Vivier |
Subject: |
[PULL 22/22] linux-user: Allow sendmsg() without IOV |
Date: |
Sat, 4 Feb 2023 17:08:30 +0100 |
From: Helge Deller <deller@gmx.de>
Applications do call sendmsg() without any IOV, e.g.:
sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=NULL, msg_iovlen=0,
msg_control=[{cmsg_len=36, cmsg_level=SOL_ALG, cmsg_type=0x2}],
msg_controllen=40, msg_flags=0}, MSG_MORE) = 0
sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="The quick brown
fox jumps over t"..., iov_len=183}],
msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_ALG,
cmsg_type=0x3}],
msg_controllen=24, msg_flags=0}, 0) = 183
The function do_sendrecvmsg_locked() is used for sndmsg() and recvmsg()
and calls lock_iovec() to lock the IOV into memory. For the first
sendmsg() above it returns NULL and thus wrongly skips the call the host
sendmsg() syscall, which will break the calling application.
Fix this issue by:
- allowing sendmsg() even with empty IOV
- skip recvmsg() if IOV is NULL
- skip both if the return code of do_sendrecvmsg_locked() != 0, which
indicates some failure like EFAULT on the IOV
Tested with the debian "ell" package with hppa guest on x86_64 host.
Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20221212173416.90590-2-deller@gmx.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/syscall.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a0d2beddaa4e..1e868e9b0e27 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3293,7 +3293,10 @@ static abi_long do_sendrecvmsg_locked(int fd, struct
target_msghdr *msgp,
target_vec, count, send);
if (vec == NULL) {
ret = -host_to_target_errno(errno);
- goto out2;
+ /* allow sending packet without any iov, e.g. with MSG_MORE flag */
+ if (!send || ret) {
+ goto out2;
+ }
}
msg.msg_iovlen = count;
msg.msg_iov = vec;
@@ -3345,7 +3348,9 @@ static abi_long do_sendrecvmsg_locked(int fd, struct
target_msghdr *msgp,
}
out:
- unlock_iovec(vec, target_vec, count, !send);
+ if (vec) {
+ unlock_iovec(vec, target_vec, count, !send);
+ }
out2:
return ret;
}
--
2.39.1
- [PULL 00/22] Linux user for 8.0 patches, Laurent Vivier, 2023/02/04
- [PULL 01/22] linux-user/strace: Constify struct flags, Laurent Vivier, 2023/02/04
- [PULL 07/22] linux-user: un-parent OBJECT(cpu) when closing thread, Laurent Vivier, 2023/02/04
- [PULL 06/22] linux-user: Add missing MAP_HUGETLB and MAP_STACK flags in strace, Laurent Vivier, 2023/02/04
- [PULL 02/22] linux-user/strace: Extract print_execve_argv() from print_execve(), Laurent Vivier, 2023/02/04
- [PULL 10/22] Revert "linux-user: add more compat ioctl definitions", Laurent Vivier, 2023/02/04
- [PULL 17/22] linux-user: Improve strace output of personality() and sysinfo(), Laurent Vivier, 2023/02/04
- [PULL 15/22] linux-user: Fix SO_ERROR return code of getsockopt(), Laurent Vivier, 2023/02/04
- [PULL 11/22] Revert "linux-user: fix compat with glibc >= 2.36 sys/mount.h", Laurent Vivier, 2023/02/04
- [PULL 19/22] linux-user: Show 4th argument of rt_sigprocmask() in strace, Laurent Vivier, 2023/02/04
- [PULL 22/22] linux-user: Allow sendmsg() without IOV,
Laurent Vivier <=
- [PULL 20/22] linux-user: Enhance strace output for various syscalls, Laurent Vivier, 2023/02/04
- [PULL 09/22] linux-user: add more netlink protocol constants, Laurent Vivier, 2023/02/04
- [PULL 03/22] linux-user/strace: Add output for execveat() syscall, Laurent Vivier, 2023/02/04
- [PULL 04/22] linux-user/syscall: Extract do_execve() from do_syscall1(), Laurent Vivier, 2023/02/04
- [PULL 05/22] linux-user/syscall: Implement execveat(), Laurent Vivier, 2023/02/04
- [PULL 18/22] linux-user: Add emulation for MADV_WIPEONFORK and MADV_KEEPONFORK in madvise(), Laurent Vivier, 2023/02/04
- [PULL 16/22] linux-user: Fix /proc/cpuinfo output for hppa, Laurent Vivier, 2023/02/04
- [PULL 13/22] linux-user: Improve strace output of getgroups() and setgroups(), Laurent Vivier, 2023/02/04
- [PULL 21/22] linux-user: Implement SOL_ALG encryption support, Laurent Vivier, 2023/02/04
- [PULL 08/22] linux-user: fix strace build w/out munlockall, Laurent Vivier, 2023/02/04