qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Andreas Schwab <schwab@suse.de>, qemu-devel@nongnu.org
Cc: Riku Voipio <riku.voipio@iki.fi>
Subject: Re: [Qemu-devel] [PATCH] linux-user: don't short-circuit read with zero length
Date: Wed, 6 Mar 2019 14:11:26 +0100	[thread overview]
Message-ID: <be7edb45-9fbe-68b6-6fc0-e4cd987a93e2@vivier.eu> (raw)
In-Reply-To: <mvm5zsxz2we.fsf@suse.de>

On 05/03/2019 17:45, Andreas Schwab wrote:
> A zero-length read still needs to do the usual checks, thus it may return
> errors like EBADF.  This makes the read syscall emulation consistent with
> the pread64 syscall emulation.
> 
> Signed-off-by: Andreas Schwab <schwab@suse.de>
> ---
>  linux-user/syscall.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index ff912e89e1..7fac8e318f 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -7047,8 +7047,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
>          _exit(arg1);
>          return 0; /* avoid warning */
>      case TARGET_NR_read:
> -        if (arg3 == 0) {
> -            return 0;
> +        if (arg2 == 0 && arg3 == 0) {
> +            return get_errno(safe_read(arg1, 0, 0));
>          } else {
>              if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
>                  return -TARGET_EFAULT;
> 

Applied to my linux-user branch.

Thanks,
Laurent

  parent reply	other threads:[~2019-03-06 13:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-05 16:45 [Qemu-devel] [PATCH] linux-user: don't short-circuit read with zero length Andreas Schwab
2019-03-05 17:31 ` Laurent Vivier
2019-03-06 13:11 ` Laurent Vivier [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-09-11 12:03 Andreas Schwab
2018-09-12 17:22 ` Richard Henderson

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=be7edb45-9fbe-68b6-6fc0-e4cd987a93e2@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=schwab@suse.de \
    /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).