Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 5f03107 in mainline


Ignore:
Timestamp:
2018-05-22T19:06:50Z (3 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
master
Children:
659bd24
Parents:
21ff054
git-author:
Jakub Jermar <jakub@…> (2018-04-25 19:39:19)
git-committer:
Jakub Jermar <jakub@…> (2018-05-22 19:06:50)
Message:

Make sure the cfg structure is inside the resource

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/virtio/virtio-pci.c

    r21ff054 r5f03107  
    3636#include <pci_dev_iface.h>
    3737
    38 static bool check_bar(virtio_dev_t *vdev, uint8_t bar)
     38static bool check_bar(virtio_dev_t *vdev, uint8_t bar, uint32_t offset,
     39    uint32_t length)
    3940{
    4041        /* We must ignore the capability if bar is greater than 5 */
     
    4647                return false;
    4748
     49        uintptr_t start = (uintptr_t) vdev->bar[bar].mapped_base;
     50        if (start + offset < start)
     51                return false;
     52        if (start + offset > start + vdev->bar[bar].mapped_size)
     53                return false;
     54        if (start + offset + length < start + offset)
     55                return false;
     56        if (start + offset + length > start + vdev->bar[bar].mapped_size)
     57                return false;
     58
    4859        return true;
    4960}
     
    5566                return;
    5667
    57         if (!check_bar(vdev, bar))
     68        if (!check_bar(vdev, bar, offset, length))
    5869                return;
    5970
     
    6980                return;
    7081
    71         if (!check_bar(vdev, bar))
     82        if (!check_bar(vdev, bar, offset, length))
    7283                return;
    7384
     
    8596                return;
    8697
    87         if (!check_bar(vdev, bar))
     98        if (!check_bar(vdev, bar, offset, length))
    8899                return;
    89100
     
    99110                return;
    100111
    101         if (!check_bar(vdev, bar))
     112        if (!check_bar(vdev, bar, offset, length))
    102113                return;
    103114
Note: See TracChangeset for help on using the changeset viewer.