lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 5 Jun 2023 14:53:56 +0800
From:   Jason Wang <jasowang@...hat.com>
To:     Angus Chen <angus.chen@...uarmicro.com>
Cc:     mst@...hat.com, virtualization@...ts.linux-foundation.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] vp_vdpa: Check queue number of vdpa device from add_config

On Fri, Jun 2, 2023 at 3:35 PM Angus Chen <angus.chen@...uarmicro.com> wrote:
>
> When add virtio_pci vdpa device,check the vqs number of device cap
> and max_vq_pairs from add_config.
>
> Signed-off-by: Angus Chen <angus.chen@...uarmicro.com>
> ---
>  drivers/vdpa/virtio_pci/vp_vdpa.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vdpa/virtio_pci/vp_vdpa.c b/drivers/vdpa/virtio_pci/vp_vdpa.c
> index 281287fae89f..4bf1ab637d32 100644
> --- a/drivers/vdpa/virtio_pci/vp_vdpa.c
> +++ b/drivers/vdpa/virtio_pci/vp_vdpa.c
> @@ -478,7 +478,7 @@ static int vp_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
>         struct device *dev = &pdev->dev;
>         struct vp_vdpa *vp_vdpa = NULL;
>         u64 device_features;
> -       int ret, i;
> +       int ret, i, queues;
>
>         vp_vdpa = vdpa_alloc_device(struct vp_vdpa, vdpa,
>                                     dev, &vp_vdpa_ops, 1, 1, name, false);
> @@ -491,7 +491,14 @@ static int vp_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
>         vp_vdpa_mgtdev->vp_vdpa = vp_vdpa;
>
>         vp_vdpa->vdpa.dma_dev = &pdev->dev;
> -       vp_vdpa->queues = vp_modern_get_num_queues(mdev);
> +       queues = vp_modern_get_num_queues(mdev);
> +       if (add_config->mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP)) {
> +               if (add_config->net.max_vq_pairs > queues / 2)
> +                       return -EINVAL;
> +               queues = min_t(u32, queues, 2 * add_config->net.max_vq_pairs);

Looks like you want to mediate the max_vqp here, but what happens:

1) harware have 4 queue paris
2) vp_vdpa cap it into 2 queue pairs
3) guest may still try to enable 4 queue paris

For 3), the kernel needs to mediate the control virtqueue which seems not easy.

How about simply starting from failing if the provisioned #qp is not
equal to the one that hardware has?

Thanks

> +       }
> +
> +       vp_vdpa->queues = queues;
>         vp_vdpa->mdev = mdev;
>
>         device_features = vp_modern_get_features(mdev);
> --
> 2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ