pci: reject too large ROMs
commit7c16b5bbb6c0f797945327d17e4be60f25a4427d
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 3 Feb 2021 13:18:27 +0000 (3 14:18 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 5 Feb 2021 13:52:58 +0000 (5 08:52 -0500)
tree0e6282cdb510ac438890d0224a814c9f9ec72979
parent923abdb4bdfb6d93bfe6c941ead70f3ea6707e40
pci: reject too large ROMs

get_image_size() returns an int64_t, which pci_add_option_rom() assigns
to an "int" without any range checking.  A 32-bit BAR could be up to
2 GiB in size, so reject anything above it.  In order to accomodate
a rounded-up size of 2 GiB, change pci_patch_ids's size argument
to unsigned.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210203131828.156467-2-pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: David Edmondson <david.edmondson@oracle.com>
hw/pci/pci.c