qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Jing Huang <jing.huang.pku@gmail.com>
Cc: riku.voipio@iki.fi, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 1/3] linux-user: pass sockaddr from host to target
Date: Mon, 16 Jul 2012 15:29:13 +0100	[thread overview]
Message-ID: <CAFEAcA8eieN24bCdu4NJKiPDVoCLcDa4=htPJ-C1Lp+UtjaEqw@mail.gmail.com> (raw)
In-Reply-To: <1342433620-3302-1-git-send-email-jing.huang.pku@gmail.com>

On 16 July 2012 11:13, Jing Huang <jing.huang.pku@gmail.com> wrote:
> This patch pass sockaddr from host to target.
>
> Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
> ---
>  linux-user/syscall.c |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 539af3f..28c8ba5 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1873,8 +1873,16 @@ static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg,
>          if (!is_error(ret)) {
>              len = ret;
>              ret = host_to_target_cmsg(msgp, &msg);
> -            if (!is_error(ret))
> +            if (!is_error(ret)) {
> +                msgp->msg_namelen = msg.msg_namelen;

You need to swap msg_namelen using tswap32().

> +                ret = host_to_target_sockaddr(tswapal(msgp->msg_name),
> +                                    msg.msg_name, msg.msg_namelen);

host_to_target_sockaddr assumes msg.msg_name isn't NULL, so you need
to enclose this in an if() to avoid that.

> +                if (ret) {
> +                    qemu_log("Failed to pass sockaddr to target guest");

Don't print any logging here -- we should only be logging
anything for (a) unimplemented features or (b) debug tracing
which is guarded by #ifdef DEBUG.

> +                    return ret;

Returning here bypasses the unlocking of the iovec and user struct.

> +                }
>                  ret = len;


...the above two points mean you wanted
  if (!is_error(ret)) {
      ret = len;
  }

here.

> +            }

-- PMM

      reply	other threads:[~2012-07-16 14:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-16 10:13 [Qemu-devel] [PATCH v2 1/3] linux-user: pass sockaddr from host to target Jing Huang
2012-07-16 14:29 ` Peter Maydell [this message]

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='CAFEAcA8eieN24bCdu4NJKiPDVoCLcDa4=htPJ-C1Lp+UtjaEqw@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=jing.huang.pku@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /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).