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:   Tue, 20 Sep 2022 10:17:55 +0800
From:   Jason Wang <jasowang@...hat.com>
To:     Zhu Lingshan <lingshan.zhu@...el.com>
Cc:     mst <mst@...hat.com>,
        virtualization <virtualization@...ts.linux-foundation.org>,
        netdev <netdev@...r.kernel.org>, kvm <kvm@...r.kernel.org>
Subject: Re: [PATCH 4/4] vDPA: Conditionally read MTU and MAC in dev cfg space

On Fri, Sep 9, 2022 at 5:05 PM Zhu Lingshan <lingshan.zhu@...el.com> wrote:
>
> The spec says:
> mtu only exists if VIRTIO_NET_F_MTU is set
> The mac address field always exists (though
> is only valid if VIRTIO_NET_F_MAC is set)
>
> So vdpa_dev_net_config_fill() should read MTU and MAC
> conditionally on the feature bits.
>
> Signed-off-by: Zhu Lingshan <lingshan.zhu@...el.com>

Acked-by: Jason Wang <jasowang@...hat.com>


> ---
>  drivers/vdpa/vdpa.c | 37 +++++++++++++++++++++++++++++--------
>  1 file changed, 29 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> index f8ff61232421..b332388d3375 100644
> --- a/drivers/vdpa/vdpa.c
> +++ b/drivers/vdpa/vdpa.c
> @@ -815,6 +815,29 @@ static int vdpa_dev_net_mq_config_fill(struct sk_buff *msg, u64 features,
>         return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, val_u16);
>  }
>
> +static int vdpa_dev_net_mtu_config_fill(struct sk_buff *msg, u64 features,
> +                                       const struct virtio_net_config *config)
> +{
> +       u16 val_u16;
> +
> +       if ((features & BIT_ULL(VIRTIO_NET_F_MTU)) == 0)
> +               return 0;
> +
> +       val_u16 = __virtio16_to_cpu(true, config->mtu);
> +
> +       return nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16);
> +}
> +
> +static int vdpa_dev_net_mac_config_fill(struct sk_buff *msg, u64 features,
> +                                       const struct virtio_net_config *config)
> +{
> +       if ((features & BIT_ULL(VIRTIO_NET_F_MAC)) == 0)
> +               return 0;
> +
> +       return  nla_put(msg, VDPA_ATTR_DEV_NET_CFG_MACADDR,
> +                       sizeof(config->mac), config->mac);
> +}
> +
>  static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msg)
>  {
>         struct virtio_net_config config = {};
> @@ -824,18 +847,10 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
>
>         vdev->config->get_config(vdev, 0, &config, sizeof(config));
>
> -       if (nla_put(msg, VDPA_ATTR_DEV_NET_CFG_MACADDR, sizeof(config.mac),
> -                   config.mac))
> -               return -EMSGSIZE;
> -
>         val_u16 = __virtio16_to_cpu(true, config.status);
>         if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_STATUS, val_u16))
>                 return -EMSGSIZE;
>
> -       val_u16 = __virtio16_to_cpu(true, config.mtu);
> -       if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, val_u16))
> -               return -EMSGSIZE;
> -
>         /* only read driver features after the feature negotiation is done */
>         status = vdev->config->get_status(vdev);
>         if (status & VIRTIO_CONFIG_S_FEATURES_OK) {
> @@ -852,6 +867,12 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms
>                               VDPA_ATTR_PAD))
>                 return -EMSGSIZE;
>
> +       if (vdpa_dev_net_mtu_config_fill(msg, features_device, &config))
> +               return -EMSGSIZE;
> +
> +       if (vdpa_dev_net_mac_config_fill(msg, features_device, &config))
> +               return -EMSGSIZE;
> +
>         return vdpa_dev_net_mq_config_fill(msg, features_device, &config);
>  }
>
> --
> 2.31.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ