mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
bhyve: verify OpRegion size
If the OpRegion size doesn't match the size of our igd_opregion struct, it's using a different layout than we're expecting. To avoid strange issues, we should exit hard. If we see any devices in the field with a different OpRegion size, we can analyse it and fix it accordingly. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D45335
This commit is contained in:
parent
5e09c5a1ed
commit
e425e601b9
|
@ -222,6 +222,13 @@ gvt_d_setup_opregion(struct pci_devinst *const pi)
|
|||
opregion->len = header->size * KB;
|
||||
munmap(header, sizeof(*header));
|
||||
|
||||
if (opregion->len != sizeof(struct igd_opregion)) {
|
||||
warnx("%s: Invalid OpRegion size of 0x%lx", __func__,
|
||||
opregion->len);
|
||||
close(memfd);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
opregion->hva = mmap(NULL, opregion->len, PROT_READ, MAP_SHARED, memfd,
|
||||
opregion->hpa);
|
||||
if (opregion->hva == MAP_FAILED) {
|
||||
|
|
Loading…
Reference in a new issue