qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Helge Deller <deller@gmx.de>,
	Richard Henderson <richard.henderson@linaro.org>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH 2/2] linux-user: Allow sendmsg() without IOV
Date: Tue, 31 Jan 2023 16:17:56 +0100	[thread overview]
Message-ID: <fd1a910e-f22a-5f72-e835-608799da38ee@vivier.eu> (raw)
In-Reply-To: <20221212173416.90590-2-deller@gmx.de>

Le 12/12/2022 à 18:34, Helge Deller a écrit :
> 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>
> ---
>   linux-user/syscall.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>




  parent reply	other threads:[~2023-01-31 15:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-12 17:34 [PATCH 1/2] linux-user: Implement SOL_ALG encryption support Helge Deller
2022-12-12 17:34 ` [PATCH 2/2] linux-user: Allow sendmsg() without IOV Helge Deller
2023-01-31 12:28   ` Laurent Vivier
2023-01-31 13:34     ` Helge Deller
2023-01-31 13:50       ` Helge Deller
2023-01-31 15:17         ` Laurent Vivier
2023-01-31 15:17   ` Laurent Vivier [this message]
2023-01-31 15:19   ` Laurent Vivier
2023-01-31 12:09 ` [PATCH 1/2] linux-user: Implement SOL_ALG encryption support Laurent Vivier
2023-01-31 15:19 ` Laurent Vivier

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=fd1a910e-f22a-5f72-e835-608799da38ee@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=deller@gmx.de \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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 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).