Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devicemodel: hw: pci: gvt: Fix out of bounds error #8118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Sep 7, 2022

  1. devicemodel: hw: pci: gvt: Fix out of bounds error

    hw/pci/gvt.c:263:41: error: array subscript 257 is above array bounds of ‘uint8_t[256]’ {aka ‘unsigned char[256]’} [-Werror=array-bounds]
      263 |                         gvt->host_config[cap_ptr + 4]);
          |                         ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
    hw/pci/gvt.c:48:17: note: while referencing ‘host_config’
       48 |         uint8_t host_config[PCI_REGMAX+1];
          |                 ^~~~~~~~~~~
    
    With the additional condition cap_ptr < PCI_REGMAX - 16 it is ensured
    that we never read config data from places we shouldn't read from.
    
    12 (offset) + 4 (pci_set_cfgdata32) = 16
    
    I would consider this a workaround that gets the job done for
    now. However with this approach we can miss the last capabilities in
    some edge cases.
    
    Tracked-On: projectacrn#8116
    
    Signed-off-by: Marius Rodi <[email protected]>
    mariusrodi committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    2f595f0 View commit details
    Browse the repository at this point in the history