linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/2] s390/vfio-ap: fix memory leak in mdev remove callback
@ 2021-06-16 14:16 Tony Krowiak
  2021-06-16 14:16 ` [PATCH v5 1/2] s390/vfio-ap: clean up mdev resources when remove callback invoked Tony Krowiak
  2021-06-16 14:16 ` [PATCH v5 2/2] s390/vfio-ap: r/w lock for PQAP interception handler function pointer Tony Krowiak
  0 siblings, 2 replies; 6+ messages in thread
From: Tony Krowiak @ 2021-06-16 14:16 UTC (permalink / raw)
  To: linux-s390, linux-kernel
  Cc: borntraeger, cohuck, pasic, jjherne, jgg, alex.williamson,
	kwankhede, frankja, david, imbrenda, hca

The mdev remove callback for the vfio_ap device driver bails out with
-EBUSY if the mdev is in use by a KVM guest. The intended purpose was
to prevent the mdev from being removed while in use; however, returning a
non-zero rc does not prevent removal of the mdev. Consequently, the memory
for the resources allocated when the mdev was created are leaked. 

To fix this issue:

* The remove callback will not terminate with -EBUSY when the mdev is in
  use by a KVM guest.
  
* The memory for the resources allocated when the mdev was created will
  be freed.
  
* Since the struct ap_matrix_mdev now gets freed while the guest is
  is still running, we need to ensure that the pointer to the function
  that handles interception of the PQAP instruction executed on the guest
  is not accessed while it is being set to NULL. To prevent this, a r/w
  lock is introduced that protects the function pointer.  
  

Tony Krowiak (2):
  s390/vfio-ap: clean up mdev resources when remove callback invoked
  s390/vfio-ap: r/w lock for PQAP interception handler function pointer

 arch/s390/include/asm/kvm_host.h      |  6 +++---
 arch/s390/kvm/kvm-s390.c              |  1 +
 arch/s390/kvm/priv.c                  |  6 +++---
 drivers/s390/crypto/vfio_ap_ops.c     | 31 ++++++++++++++-------------
 drivers/s390/crypto/vfio_ap_private.h |  2 +-
 5 files changed, 24 insertions(+), 22 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-06-17 19:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16 14:16 [PATCH v5 0/2] s390/vfio-ap: fix memory leak in mdev remove callback Tony Krowiak
2021-06-16 14:16 ` [PATCH v5 1/2] s390/vfio-ap: clean up mdev resources when remove callback invoked Tony Krowiak
2021-06-17  9:01   ` Christian Borntraeger
2021-06-16 14:16 ` [PATCH v5 2/2] s390/vfio-ap: r/w lock for PQAP interception handler function pointer Tony Krowiak
2021-06-17 12:23   ` Christian Borntraeger
2021-06-17 19:12     ` Tony Krowiak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).