Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1447206
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/3] qemu: Implement virtio-pstore device |
| Date | 2016-07-20 14:40 +0200 |
| Message-ID | <rWYX7-1pp-11@gated-at.bofh.it> (permalink) |
| References | <rW8vv-1wg-1@gated-at.bofh.it> <rW8vv-1wg-7@gated-at.bofh.it> <rWdER-4PX-1@gated-at.bofh.it> <rWFrs-5Qf-23@gated-at.bofh.it> <rWY13-P5-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, Jul 20, 2016 at 09:21:08AM +0100, Stefan Hajnoczi wrote:
> On Wed, Jul 20, 2016 at 12:48:39AM +0900, Namhyung Kim wrote:
> > Hello,
> >
> > On Mon, Jul 18, 2016 at 11:03:53AM +0100, Stefan Hajnoczi wrote:
> > > On Mon, Jul 18, 2016 at 01:37:40PM +0900, Namhyung Kim wrote:
> > > > +static void virtio_pstore_handle_io(VirtIODevice *vdev, VirtQueue *vq)
> > > > +{
> > > > + VirtIOPstore *s = VIRTIO_PSTORE(vdev);
> > > > + VirtQueueElement *elem;
> > > > + struct virtio_pstore_hdr *hdr;
> > > > + ssize_t len;
> > > > +
> > > > + for (;;) {
> > > > + elem = virtqueue_pop(vq, sizeof(VirtQueueElement));
> > > > + if (!elem) {
> > > > + return;
> > > > + }
> > > > +
> > > > + hdr = elem->out_sg[0].iov_base;
> > > > + if (elem->out_sg[0].iov_len != sizeof(*hdr)) {
> > > > + error_report("invalid header size: %u",
> > > > + (unsigned)elem->out_sg[0].iov_len);
> > > > + exit(1);
> > > > + }
> > >
> > > Please use iov_to_buf() instead of directly accessing out_sg[]. Virtio
> > > devices are not supposed to assume a particular iovec layout. In other
> > > words, virtio_pstore_hdr could be split across multiple out_sg[] iovecs.
> > >
> > > You must also copy in data (similar to Linux syscall implementations) to
> > > prevent the guest from modifying data while the command is processed.
> > > Such race conditions could lead to security bugs.
> >
> > By accessing elem->out_sg[0].iov_base directly, I abused it as an
> > in-and-out buffer. But it seems not allowed by the virtio spec, do I
> > have to use separate buffers for request and response?
>
> Yes, a virtqueue element has (host read-only) out buffers followed by
> (host write-only) in buffers.
Thanks for clarification. I'll split them.
Thanks,
Namhyung
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC/PATCHSET 0/3] virtio-pstore: Implement virtio pstore device Namhyung Kim <namhyung@kernel.org> - 2016-07-18 06:40 +0200
[PATCH 1/3] virtio: Basic implementation of virtio pstore driver Namhyung Kim <namhyung@kernel.org> - 2016-07-18 06:40 +0200
Re: [PATCH 1/3] virtio: Basic implementation of virtio pstore driver Kees Cook <keescook@chromium.org> - 2016-07-18 07:20 +0200
Re: [PATCH 1/3] virtio: Basic implementation of virtio pstore driver Namhyung Kim <namhyung@kernel.org> - 2016-07-18 08:00 +0200
Re: [PATCH 1/3] virtio: Basic implementation of virtio pstore driver Kees Cook <keescook@chromium.org> - 2016-07-18 20:00 +0200
Re: [PATCH 1/3] virtio: Basic implementation of virtio pstore driver Namhyung Kim <namhyung@kernel.org> - 2016-07-19 15:50 +0200
Re: [PATCH 1/3] virtio: Basic implementation of virtio pstore driver Namhyung Kim <namhyung@kernel.org> - 2016-07-19 17:40 +0200
Re: [PATCH 1/3] virtio: Basic implementation of virtio pstore driver Namhyung Kim <namhyung@kernel.org> - 2016-07-20 15:00 +0200
Re: [PATCH 1/3] virtio: Basic implementation of virtio pstore driver Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-07-18 10:00 +0200
Re: [PATCH 1/3] virtio: Basic implementation of virtio pstore driver Namhyung Kim <namhyung@kernel.org> - 2016-07-18 10:40 +0200
Re: [PATCH 1/3] virtio: Basic implementation of virtio pstore driver Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-07-18 11:10 +0200
[PATCH 2/3] qemu: Implement virtio-pstore device Namhyung Kim <namhyung@kernel.org> - 2016-07-18 06:40 +0200
Re: [PATCH 2/3] qemu: Implement virtio-pstore device Christian Borntraeger <borntraeger@de.ibm.com> - 2016-07-18 09:30 +0200
Re: [PATCH 2/3] qemu: Implement virtio-pstore device Namhyung Kim <namhyung@kernel.org> - 2016-07-18 10:40 +0200
Re: [PATCH 2/3] qemu: Implement virtio-pstore device Stefan Hajnoczi <stefanha@gmail.com> - 2016-07-18 12:10 +0200
Re: [PATCH 2/3] qemu: Implement virtio-pstore device Namhyung Kim <namhyung@kernel.org> - 2016-07-18 16:30 +0200
Re: [PATCH 2/3] qemu: Implement virtio-pstore device Stefan Hajnoczi <stefanha@gmail.com> - 2016-07-20 13:40 +0200
Re: [PATCH 2/3] qemu: Implement virtio-pstore device Namhyung Kim <namhyung@kernel.org> - 2016-07-20 14:50 +0200
Re: [PATCH 2/3] qemu: Implement virtio-pstore device Namhyung Kim <namhyung@kernel.org> - 2016-07-19 17:50 +0200
Re: [PATCH 2/3] qemu: Implement virtio-pstore device Stefan Hajnoczi <stefanha@gmail.com> - 2016-07-20 13:40 +0200
Re: [PATCH 2/3] qemu: Implement virtio-pstore device Namhyung Kim <namhyung@kernel.org> - 2016-07-20 14:40 +0200
[PATCH 3/3] kvmtool: Implement virtio-pstore device Namhyung Kim <namhyung@kernel.org> - 2016-07-18 06:40 +0200
csiph-web