[PATCH v3 0/2] s390/vfio-ap: fix memory leak in mdev remove callback

From: Tony Krowiak
Date: Wed May 19 2021 - 12:09:12 EST


Fixes a memory leak in the mdev remove callback when invoked while the
mdev is in use by a KVM guest. Instead of returning -EBUSY from the
callback, a full cleanup of the resources allocated to the mdev is
performed because regardless of the value returned from the function, the
mdev is removed from sysfs.

The cleanup of resources allocated to the mdev may coincide with the
interception of the PQAP(AQIC) instruction in which case data needed to
handle the interception may get removed. A patch is included in this series
to synchronize access to resources needed by the interception handler to
protect against invalid memory accesses.

Change log:
v2 -> v3:
--------
* Added a patch to control access to the PQAP(AQIC) hook using RCU

v1 -> v2:
--------
* Call vfio_ap_mdev_unset_kvm() function from the remove callback instead
of merely clearing the guest's APCB.

Tony Krowiak (2):
s390/vfio-ap: fix memory leak in mdev remove callback
s390/vfio-ap: control access to PQAP(AQIC) interception handler

arch/s390/include/asm/kvm_host.h | 1 +
arch/s390/kvm/priv.c | 47 +++++++++++++---------
drivers/s390/crypto/vfio_ap_ops.c | 67 +++++++++++++++++++++----------
3 files changed, 75 insertions(+), 40 deletions(-)

--
2.30.2