All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] linux-user: prevent NULL dereference in do_sendrecvmsg_locked()
@ 2025-08-14 10:52 gerben
  2025-08-14 10:57 ` Manos Pitsidianakis
  0 siblings, 1 reply; 3+ messages in thread
From: gerben @ 2025-08-14 10:52 UTC (permalink / raw)
  To: qemu-devel, richard.henderson, peter.maydell; +Cc: sdl.qemu

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] linux-user: prevent NULL dereference in do_sendrecvmsg_locked()
  2025-08-14 10:52 [PATCH] linux-user: prevent NULL dereference in do_sendrecvmsg_locked() gerben
@ 2025-08-14 10:57 ` Manos Pitsidianakis
  2025-08-14 11:19   ` gerben
  0 siblings, 1 reply; 3+ messages in thread
From: Manos Pitsidianakis @ 2025-08-14 10:57 UTC (permalink / raw)
  To: gerben
  Cc: open list:ARM SMMU <qemu-arm@nongnu.org>, ,
	Richard Henderson, Peter Maydell, sdl.qemu

[-- Attachment #1: Type: text/plain, Size: 1287 bytes --]

On Thu, 14 Aug 2025, 13:53 , <gerben@altlinux.org> wrote:

> 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) {
>

Surely you meant ` && msg.msg_iov` instead of dereferencing the iov_len
field? According to the commit message.

             void *host_msg;
>
>              host_msg = g_malloc(msg.msg_iov->iov_len);
> --
> 2.42.2
>
>
>

[-- Attachment #2: Type: text/html, Size: 2361 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] linux-user: prevent NULL dereference in do_sendrecvmsg_locked()
  2025-08-14 10:57 ` Manos Pitsidianakis
@ 2025-08-14 11:19   ` gerben
  0 siblings, 0 replies; 3+ messages in thread
From: gerben @ 2025-08-14 11:19 UTC (permalink / raw)
  To: manos.pitsidianakis
  Cc: qemu-devel, richard.henderson, peter.maydell, sdl.qemu

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 66 bytes --]

Yes, indeed — my mistake. I’ve sent v2 with the fix. Thanks.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-14 11:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14 10:52 [PATCH] linux-user: prevent NULL dereference in do_sendrecvmsg_locked() gerben
2025-08-14 10:57 ` Manos Pitsidianakis
2025-08-14 11:19   ` gerben

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.