powerpc fixes for 6.13 #3

- Add close() callback in vas_vm_ops struct for proper cleanup
 
 Thanks to: Haren Myneni
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEqX2DNAOgU8sBX3pRpnEsdPSHZJQFAmduTGMACgkQpnEsdPSH
 ZJSpGRAAgrC9bSMEarUY6S1vezEAgt9B6po8ONRF0HMHUQnpADLnkRjLGzVxg0aD
 NGB43bmo/RJqrr7xN9sTFoK5K3dAxADDibbVJ8N5euWXmu4AD49LCydE7z0qU4Qg
 hSpWS/vZyNnlx20W0eZI6cAhcANvHswLR4GeDsDd1QT6MoH+w9ojoelIKWkfFMAY
 gIFESHKUsC+qLOLlv/PXrIC5c6mOe/CYZLcLLAuC+zcan7wKd37S80LxLbgLnJgv
 PPf/sqeZr75rS1YZ+BKdAGrXEfDOaxiY0Y0fHT9I7EDST+nM0AaIREjJw+kqLIB/
 8UC030PJk7w6peEVqzK1CdqNW5vifd+htqXLXGc7o16VZp9JQc/tySMqtxCqLiMT
 Fc6Nlo2LBk8RP3gNgGykZZrubsVS+91jzZMosZzv31JR4atuVfNaa1X1vvgtif09
 Qvg/hQgno5sjKhyRLsulMrEzAQqipfCKbUuHVqo4MaPJW2sTQ15W6/F6lm8s9TKr
 xN4bjuhAKTSviXRc9EgC2h9xQdtp0/yivHyrUgd/rrx1I5ieW91YsipfACjtK0V3
 rx/JI2H27Fy74yMc93CHenn81OTZ5EDZhVIzMWqD4LPs3UV1daR/elLdy0fUso81
 vc2BpePkwCcK6cc41Nnciml6aYwsyDELaE+ghky/qlBIx/NXG9Y=
 =grGb
 -----END PGP SIGNATURE-----

Merge tag 'powerpc-6.13-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux

Pull powerpc fix from Madhavan Srinivasan:

 - Add close() callback in vas_vm_ops struct for proper cleanup

Thanks to Haren Myneni.

* tag 'powerpc-6.13-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
  powerpc/pseries/vas: Add close() callback in vas_vm_ops struct
This commit is contained in:
Linus Torvalds 2024-12-27 11:06:29 -08:00
commit eff4f67583

View File

@ -464,7 +464,43 @@ static vm_fault_t vas_mmap_fault(struct vm_fault *vmf)
return VM_FAULT_SIGBUS;
}
/*
* During mmap() paste address, mapping VMA is saved in VAS window
* struct which is used to unmap during migration if the window is
* still open. But the user space can remove this mapping with
* munmap() before closing the window and the VMA address will
* be invalid. Set VAS window VMA to NULL in this function which
* is called before VMA free.
*/
static void vas_mmap_close(struct vm_area_struct *vma)
{
struct file *fp = vma->vm_file;
struct coproc_instance *cp_inst = fp->private_data;
struct vas_window *txwin;
/* Should not happen */
if (!cp_inst || !cp_inst->txwin) {
pr_err("No attached VAS window for the paste address mmap\n");
return;
}
txwin = cp_inst->txwin;
/*
* task_ref.vma is set in coproc_mmap() during mmap paste
* address. So it has to be the same VMA that is getting freed.
*/
if (WARN_ON(txwin->task_ref.vma != vma)) {
pr_err("Invalid paste address mmaping\n");
return;
}
mutex_lock(&txwin->task_ref.mmap_mutex);
txwin->task_ref.vma = NULL;
mutex_unlock(&txwin->task_ref.mmap_mutex);
}
static const struct vm_operations_struct vas_vm_ops = {
.close = vas_mmap_close,
.fault = vas_mmap_fault,
};