qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: "M. Mohan Kumar" <mohan@in.ibm.com>
Cc: qemu-devel@nongnu.org, aneesh.kumar@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH V2 04/12] hw/9pfs: Open and create files
Date: Thu, 17 Nov 2011 15:46:12 +0000	[thread overview]
Message-ID: <CAJSP0QX7wK_sd1=yyiDt1uh0KhCSCUkQXvFaOWFmxQB2s3JyBA@mail.gmail.com> (raw)
In-Reply-To: <1321358265-10924-5-git-send-email-mohan@in.ibm.com>

On Tue, Nov 15, 2011 at 11:57 AM, M. Mohan Kumar <mohan@in.ibm.com> wrote:
> +static void send_fd(int sockfd, int fd)
> +{
> +    struct msghdr msg = { };
> +    struct iovec iov;
> +    struct cmsghdr *cmsg;
> +    int retval, data;
> +    union MsgControl msg_control;
> +
> +    iov.iov_base = &data;
> +    iov.iov_len = sizeof(data);
> +
> +    memset(&msg, 0, sizeof(msg));
> +    msg.msg_iov = &iov;
> +    msg.msg_iovlen = 1;
> +    /* No ancillary data on error */
> +    if (fd < 0) {
> +        /*
> +         * fd is really negative errno if the request failed. Or simply
> +         * zero if the request is successful and it doesn't need a file
> +         * descriptor.
> +         */

It cannot be zero because the if statement is fd < 0.  The comment is confusing.

> +/*
> + * create a file and send fd on success
> + * return -errno on error
> + */
> +static int do_create(struct iovec *iovec)
> +{
> +    V9fsString path;
> +    int flags, fd, mode, uid, gid, cur_uid, cur_gid;
> +    proxy_unmarshal(iovec, 1, HDR_SZ, "sdddd",
> +                   &path, &flags, &mode, &uid, &gid);

Unmarshalling can fail if the iovec size does not match what the
format string describes.  We should fail here rather than continuing
on.  If execution continues some of the variables may be
uninitialized.

Stefan

  reply	other threads:[~2011-11-17 15:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15 11:57 [Qemu-devel] [PATCH V2 00/12] Proxy FS driver for VirtFS M. Mohan Kumar
2011-11-15 11:57 ` [Qemu-devel] [PATCH V2 01/12] hw/9pfs: Move pdu_marshal/unmarshal code to a seperate file M. Mohan Kumar
2011-11-15 11:57 ` [Qemu-devel] [PATCH V2 02/12] hw/9pfs: Add new proxy filesystem driver M. Mohan Kumar
2011-11-15 11:57 ` [Qemu-devel] [PATCH V2 03/12] hw/9pfs: File system helper process for qemu 9p proxy FS M. Mohan Kumar
2011-11-15 14:03   ` Stefan Hajnoczi
2011-11-16  8:51     ` M. Mohan Kumar
2011-11-16 10:23       ` Stefan Hajnoczi
2011-11-15 11:57 ` [Qemu-devel] [PATCH V2 04/12] hw/9pfs: Open and create files M. Mohan Kumar
2011-11-17 15:46   ` Stefan Hajnoczi [this message]
2011-11-15 11:57 ` [Qemu-devel] [PATCH V2 05/12] hw/9pfs: Create other filesystem objects M. Mohan Kumar
2011-11-15 11:57 ` [Qemu-devel] [PATCH V2 06/12] hw/9pfs: Add stat/readlink/statfs for proxy FS M. Mohan Kumar
2011-11-15 11:57 ` [Qemu-devel] [PATCH V2 07/12] hw/9pfs: File ownership and others M. Mohan Kumar
2011-11-15 11:57 ` [Qemu-devel] [PATCH V2 08/12] hw/9pfs: xattr interfaces in proxy filesystem driver M. Mohan Kumar
2011-11-15 11:57 ` [Qemu-devel] [PATCH V2 09/12] hw/9pfs: Proxy getversion M. Mohan Kumar
2011-11-15 11:57 ` [Qemu-devel] [PATCH V2 10/12] hw/9pfs: Documentation changes related to proxy fs M. Mohan Kumar
2011-11-15 11:57 ` [Qemu-devel] [PATCH V2 11/12] hw/9pfs: man page for proxy helper M. Mohan Kumar
2011-11-15 11:57 ` [Qemu-devel] [PATCH V2 12/12] hw/9pfs: Add support to use named socket for proxy FS M. Mohan Kumar
2011-11-15 11:57 ` [Qemu-devel] [PATCH 00/12] Proxy FS driver for VirtFS M. Mohan Kumar
2011-11-15 12:09 ` [Qemu-devel] [PATCH V2 " M. Mohan Kumar
2011-11-17 16:00   ` Stefan Hajnoczi

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='CAJSP0QX7wK_sd1=yyiDt1uh0KhCSCUkQXvFaOWFmxQB2s3JyBA@mail.gmail.com' \
    --to=stefanha@gmail.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=mohan@in.ibm.com \
    --cc=qemu-devel@nongnu.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).