From: Stefan Hajnoczi <stefanha@gmail.com>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
Thomas Huth <thuth@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Cornelia Huck <cohuck@redhat.com>,
qemu-devel@nongnu.org, virtio-fs@redhat.com,
Stefan Hajnoczi <stefanha@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
vgoyal@redhat.com
Subject: Re: [RFC 3/3] tests/vhost-user-fs-test: add vhost-user-fs test case
Date: Tue, 5 Nov 2019 17:02:52 +0100 [thread overview]
Message-ID: <20191105160252.GF166646@stefanha-x1.localdomain> (raw)
In-Reply-To: <20191029003605.GC2508@work-vm>
[-- Attachment #1: Type: text/plain, Size: 1758 bytes --]
On Tue, Oct 29, 2019 at 12:36:05AM +0000, Dr. David Alan Gilbert wrote:
> * Stefan Hajnoczi (stefanha@redhat.com) wrote:
> > +static void after_test(void *arg G_GNUC_UNUSED)
> > +{
> > + unlink(socket_path);
> > +
> > + remove_dir_and_children(shared_dir);
>
> This scares me. Especially since it's running as root.
> Can we add a bunch of paranoid checks to make sure it doesn't
> end up rm -rf / ?
Yes, we can resolve the path and check it is not "/".
> > +/* Open a file by nodeid using FUSE_OPEN */
> > +static int32_t fuse_open(QVirtioFS *vfs, uint64_t nodeid, uint32_t flags,
> > + uint64_t *fh)
> > +{
> > + struct fuse_in_header in_hdr = {
> > + .opcode = guest32(FUSE_OPEN),
> > + .unique = guest64(virtio_fs_get_unique(vfs)),
> > + .nodeid = guest64(nodeid),
> > + };
> > + struct fuse_open_in in = {
> > + .flags = guest32(flags),
> > + };
> > + struct iovec sg_in[] = {
> > + { .iov_base = &in_hdr, .iov_len = sizeof(in_hdr) },
> > + { .iov_base = &in, .iov_len = sizeof(in) },
> > + };
> > + struct fuse_out_header out_hdr;
> > + struct fuse_open_out out;
> > + struct iovec sg_out[] = {
> > + { .iov_base = &out_hdr, .iov_len = sizeof(out_hdr) },
> > + { .iov_base = &out, .iov_len = sizeof(out) },
> > + };
>
> I wonder if anything can be done to reduce the size of the iovec boiler
> plate?
I'm not aware of a clean way to build the iovec array automatically but
we could do this if you prefer it:
#define IOVEC(elem) { .iov_base = &elem, .iov_len = sizeof(elem) }
struct iovec sg_in[] = {
IOVEC(in_hdr),
IOVEC(in),
};
Do you find this nicer?
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-11-05 16:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-25 10:01 [RFC 0/3] tests/vhost-user-fs-test: add vhost-user-fs test case Stefan Hajnoczi
2019-10-25 10:01 ` [RFC 1/3] WIP virtiofsd: import Linux <fuse.h> header file Stefan Hajnoczi
2019-10-26 21:49 ` Michael S. Tsirkin
2019-10-27 12:36 ` Stefan Hajnoczi
2020-06-01 10:28 ` Alex Bennée
2020-06-01 15:55 ` Stefan Hajnoczi
2019-10-25 10:01 ` [RFC 2/3] qgraph: add an "after" test callback function Stefan Hajnoczi
2019-10-25 10:01 ` [RFC 3/3] tests/vhost-user-fs-test: add vhost-user-fs test case Stefan Hajnoczi
2019-10-29 0:36 ` Dr. David Alan Gilbert
2019-11-05 16:02 ` Stefan Hajnoczi [this message]
2019-11-07 12:26 ` Dr. David Alan Gilbert
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=20191105160252.GF166646@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=cohuck@redhat.com \
--cc=dgilbert@redhat.com \
--cc=lvivier@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
--cc=vgoyal@redhat.com \
--cc=virtio-fs@redhat.com \
/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).