1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

kernel: fix unsafe use of readlink

This commit is contained in:
Niklas Eiling 2022-11-08 11:37:29 -05:00 committed by Steffen Vogel
parent ccbab2e3e4
commit 80268bc5fb
2 changed files with 6 additions and 1 deletions

View file

@ -376,7 +376,10 @@ int
Device::getIOMMUGroup() const
{
int ret;
char *group, link[1024], sysfs[1024];
char *group;
//readlink does not add a null terminator!
char link[1024] = {0};
char sysfs[1024];
snprintf(sysfs, sizeof(sysfs), "%s/bus/pci/devices/%04x:%02x:%02x.%x/iommu_group", SYSFS_PATH,
slot.domain, slot.bus, slot.device, slot.function);

View file

@ -604,6 +604,8 @@ Device::pciMsiInit(int efds[])
auto *irqSet = reinterpret_cast<struct vfio_irq_set*>(irqSetBuf);
irqSet->argsz = irqSetSize;
// DATA_EVENTFD binds the interrupt to the provided eventfd.
// SET_ACTION_TRIGGER enables kernel->userspace signalling.
irqSet->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER;
irqSet->index = VFIO_PCI_MSI_IRQ_INDEX;
irqSet->start = 0;