WSL2-Linux-Kernel/drivers/vfio
Steve Sistare 5f63c879ca vfio/type1: restore locked_vm
commit 90fdd158a6 upstream.

When a vfio container is preserved across exec or fork-exec, the new
task's mm has a locked_vm count of 0.  After a dma vaddr is updated using
VFIO_DMA_MAP_FLAG_VADDR, locked_vm remains 0, and the pinned memory does
not count against the task's RLIMIT_MEMLOCK.

To restore the correct locked_vm count, when VFIO_DMA_MAP_FLAG_VADDR is
used and the dma's mm has changed, add the dma's locked_vm count to
the new mm->locked_vm, subject to the rlimit, and subtract it from the
old mm->locked_vm.

Fixes: c3cbab24db ("vfio/type1: implement interfaces to update vaddr")
Cc: stable@vger.kernel.org
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/1675184289-267876-5-git-send-email-steven.sistare@oracle.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-03-10 09:40:13 +01:00
..
fsl-mc
mdev
pci
platform vfio: platform: Do not pass return buffer to ACPI _RST method 2022-12-31 13:14:27 +01:00
Kconfig
Makefile
vfio.c
vfio_iommu_spapr_tce.c
vfio_iommu_type1.c vfio/type1: restore locked_vm 2023-03-10 09:40:13 +01:00
vfio_spapr_eeh.c
virqfd.c