On 1/15/2016 12:34 PM, Yuanhan Liu wrote:
> Modern (v1.0) virtio pci device defines several pci capabilities.
> Each cap has a configure structure corresponding to it, and the
> cap.bar and cap.offset fields tell us where to find it.
>

[snip]

>  
> +static void *
> +get_cfg_addr(struct rte_pci_device *dev, struct virtio_pci_cap *cap)
> +{
> +     uint8_t  bar    = cap->bar;
> +     uint32_t length = cap->length;
> +     uint32_t offset = cap->offset;
> +     uint8_t *base;
> +
> +     if (bar > 5) {
> +             PMD_INIT_LOG(ERR, "invalid bar: %u", bar);
> +             return NULL;
> +     }
> +
> +     if (offset + length > dev->mem_resource[bar].len) {

offset + length could overflow 32bit limit

> +             PMD_INIT_LOG(ERR,
> +                     "invalid cap: overflows bar space: %u > %"PRIu64,
> +                     offset + length, dev->mem_resource[bar].len);
> +             return NULL;
> +     }
> +
> +     

[snip]

Reply via email to