qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1 1/4] virtio: protect non-modern devices from too big virtq


From: Stefan Hajnoczi
Subject: Re: [PATCH v1 1/4] virtio: protect non-modern devices from too big virtqueue size setting
Date: Wed, 6 Nov 2019 10:01:19 +0100
User-agent: Mutt/1.12.1 (2019-06-15)

On Wed, Nov 06, 2019 at 07:46:31AM +0000, Denis Plotnikov wrote:
> 
> On 05.11.2019 23:56, Michael S. Tsirkin wrote:
> > On Tue, Nov 05, 2019 at 07:11:02PM +0300, Denis Plotnikov wrote:
> >> The patch protects from creating illegal virtio device configuration
> >> via direct virtqueue size property setting.
> >>
> >> Signed-off-by: Denis Plotnikov <address@hidden>
> >> ---
> >>   hw/virtio/virtio-blk-pci.c  |  9 +++++++++
> >>   hw/virtio/virtio-scsi-pci.c | 10 ++++++++++
> >>   2 files changed, 19 insertions(+)
> >>
> >> diff --git a/hw/virtio/virtio-blk-pci.c b/hw/virtio/virtio-blk-pci.c
> >> index 60c9185c39..6177ff1df8 100644
> >> --- a/hw/virtio/virtio-blk-pci.c
> >> +++ b/hw/virtio/virtio-blk-pci.c
> >> @@ -48,6 +48,15 @@ static void virtio_blk_pci_realize(VirtIOPCIProxy 
> >> *vpci_dev, Error **errp)
> >>   {
> >>       VirtIOBlkPCI *dev = VIRTIO_BLK_PCI(vpci_dev);
> >>       DeviceState *vdev = DEVICE(&dev->vdev);
> >> +    bool modern = virtio_pci_modern(vpci_dev);
> >> +    uint32_t queue_size = dev->vdev.conf.queue_size;
> >> +
> >> +    if (!modern && queue_size > 128) {
> >> +        error_setg(errp,
> >> +                   "too big queue size (%u, max: 128) "
> >> +                   "for non-modern virtio device", queue_size);
> >> +        return;
> >> +    }
> >
> > this enables for transitional so still visible to legacy
> > interface. I am guessing you want to check whether
> > device is accessed through the modern interface instead.
> 
> My goal is to not break something when I'm setting the queue size > 128 
> (taking into account the current seabios queue size restriction to 128). 
> I'm not quite sure what to check. Could I ask why one want to the check 
> whether accessing through the modern interface and how it could be checked?

virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)

Stefan

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]