From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>, Icenowy Zheng <uwu@icenowy.me>
Subject: [PULL 4/4] linux-user: always translate cmsg when recvmsg
Date: Thu, 3 Nov 2022 09:49:25 +0100 [thread overview]
Message-ID: <20221103084925.3860524-5-laurent@vivier.eu> (raw)
In-Reply-To: <20221103084925.3860524-1-laurent@vivier.eu>
From: Icenowy Zheng <uwu@icenowy.me>
It's possible that a message contains both normal payload and ancillary
data in the same message, and even if no ancillary data is available
this information should be passed to the target, otherwise the target
cmsghdr will be left uninitialized and the target is going to access
uninitialized memory if it expects cmsg.
Always call the function that translate cmsg when recvmsg, because that
function should be empty-cmsg-safe (it creates an empty cmsg in the
target).
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20221028081220.1604244-1-uwu@icenowy.me>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/syscall.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8b18adfba894..24b25759beab 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3353,7 +3353,8 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
if (fd_trans_host_to_target_data(fd)) {
ret = fd_trans_host_to_target_data(fd)(msg.msg_iov->iov_base,
MIN(msg.msg_iov->iov_len, len));
- } else {
+ }
+ if (!is_error(ret)) {
ret = host_to_target_cmsg(msgp, &msg);
}
if (!is_error(ret)) {
--
2.37.3
next prev parent reply other threads:[~2022-11-03 8:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-03 8:49 [PULL 0/4] Linux user for 7.2 patches Laurent Vivier
2022-11-03 8:49 ` [PULL 1/4] linux-user/hppa: Detect glibc ABORT_INSTRUCTION and EXCP_BREAK handler Laurent Vivier
2022-11-03 8:49 ` [PULL 2/4] linux-user: Add close_range() syscall Laurent Vivier
2022-11-03 8:49 ` [PULL 3/4] linux-user: Add strace output for timer_settime64() syscall Laurent Vivier
2022-11-03 8:49 ` Laurent Vivier [this message]
2022-11-03 21:27 ` [PULL 0/4] Linux user for 7.2 patches Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221103084925.3860524-5-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=uwu@icenowy.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).