vfio/type1: prevent underflow of locked_vm via exec()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
vfio/type1: prevent underflow of locked_vm via exec()
When a vfio container is preserved across exec, the task does not change, but it gets a new mm with locked_vm=0, and loses the count from existing dma mappings. If the user later unmaps a dma mapping, locked_vm underflows to a large unsigned value, and a subsequent dma map request fails with ENOMEM in __account_locked_vm.
To avoid underflow, grab and save the mm at the time a dma is mapped. Use that mm when adjusting locked_vm, rather than re-acquiring the saved task's mm, which may have changed. If the saved mm is dead, do nothing.
locked_vm is incremented for existing mappings in a subsequent patch.
From the CVE record · Linux
In the Linux kernel's vfio/type1 component, a VFIO container preserved across exec can retain DMA mappings while the task receives a new memory context with a zero locked_vm count. If the user then unmaps a DMA mapping, the count can underflow, causing a subsequent DMA map request to fail with ENOMEM. This requires a local user to preserve the container across exec and perform the unmap and map operations.
Engineers running Linux kernels with vfio/type1 should check their versions against the vendor advisory; affected versions were not provided.