From: gerben@altlinux.org
To: qemu-devel@nongnu.org, richard.henderson@linaro.org,
peter.maydell@linaro.org
Cc: sdl.qemu@linuxtesting.org
Subject: [PATCH] linux-user: prevent NULL dereference in do_sendrecvmsg_locked()
Date: Thu, 14 Aug 2025 13:52:08 +0300 [thread overview]
Message-ID: <20250814105236.13344-1-gerben@altlinux.org> (raw)
From: Denis Rastyogin <gerben@altlinux.org>
fd_trans_target_to_host_data() in do_sendrecvmsg_locked() may be
called when msg.msg_iov is NULL, for example when sending with
MSG_MORE and no actual iovec data is present. Dereferencing
msg.msg_iov in this case would lead to a NULL pointer access.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Reported-by: Alexey Appolonov <alexey@altlinux.org>
Signed-off-by: Denis Rastyogin <gerben@altlinux.org>
---
linux-user/syscall.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 59b2080b98..c7e6c53f08 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3300,7 +3300,7 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
msg.msg_iov = vec;
if (send) {
- if (fd_trans_target_to_host_data(fd)) {
+ if (fd_trans_target_to_host_data(fd) && msg.msg_iov->iov_len) {
void *host_msg;
host_msg = g_malloc(msg.msg_iov->iov_len);
--
2.42.2
next reply other threads:[~2025-08-14 10:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-14 10:52 gerben [this message]
2025-08-14 10:57 ` [PATCH] linux-user: prevent NULL dereference in do_sendrecvmsg_locked() Manos Pitsidianakis
2025-08-14 11:19 ` gerben
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=20250814105236.13344-1-gerben@altlinux.org \
--to=gerben@altlinux.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sdl.qemu@linuxtesting.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.