[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH V2 04/12] hw/9pfs: Open and create files
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH V2 04/12] hw/9pfs: Open and create files |
Date: |
Thu, 17 Nov 2011 15:46:12 +0000 |
On Tue, Nov 15, 2011 at 11:57 AM, M. Mohan Kumar <address@hidden> 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
- [Qemu-devel] [PATCH V2 00/12] Proxy FS driver for VirtFS, M. Mohan Kumar, 2011/11/15
- [Qemu-devel] [PATCH V2 07/12] hw/9pfs: File ownership and others, M. Mohan Kumar, 2011/11/15
- [Qemu-devel] [PATCH V2 08/12] hw/9pfs: xattr interfaces in proxy filesystem driver, M. Mohan Kumar, 2011/11/15
- [Qemu-devel] [PATCH V2 01/12] hw/9pfs: Move pdu_marshal/unmarshal code to a seperate file, M. Mohan Kumar, 2011/11/15
- [Qemu-devel] [PATCH V2 06/12] hw/9pfs: Add stat/readlink/statfs for proxy FS, M. Mohan Kumar, 2011/11/15
- [Qemu-devel] [PATCH V2 05/12] hw/9pfs: Create other filesystem objects, M. Mohan Kumar, 2011/11/15
- [Qemu-devel] [PATCH V2 04/12] hw/9pfs: Open and create files, M. Mohan Kumar, 2011/11/15
- Re: [Qemu-devel] [PATCH V2 04/12] hw/9pfs: Open and create files,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH V2 09/12] hw/9pfs: Proxy getversion, M. Mohan Kumar, 2011/11/15
- [Qemu-devel] [PATCH V2 10/12] hw/9pfs: Documentation changes related to proxy fs, M. Mohan Kumar, 2011/11/15
- [Qemu-devel] [PATCH V2 02/12] hw/9pfs: Add new proxy filesystem driver, M. Mohan Kumar, 2011/11/15
- [Qemu-devel] [PATCH V2 12/12] hw/9pfs: Add support to use named socket for proxy FS, M. Mohan Kumar, 2011/11/15
- [Qemu-devel] [PATCH V2 03/12] hw/9pfs: File system helper process for qemu 9p proxy FS, M. Mohan Kumar, 2011/11/15
- Re: [Qemu-devel] [PATCH V2 00/12] Proxy FS driver for VirtFS, M. Mohan Kumar, 2011/11/15