KVM: s390: pv: avoid double free of sida page
authorClaudio Imbrenda <imbrenda@linux.ibm.com>
Mon, 20 Sep 2021 13:24:50 +0000 (15:24 +0200)
committerChristian Borntraeger <borntraeger@de.ibm.com>
Mon, 25 Oct 2021 07:20:38 +0000 (09:20 +0200)
commitd4074324b07a94a1fca476d452dfbb3a4e7bf656
tree7754a919724458c5cae701b701177d2c80f86c7e
parent57c5df13eca4017ed28f9375dc1d246ec0f54217
KVM: s390: pv: avoid double free of sida page

If kvm_s390_pv_destroy_cpu is called more than once, we risk calling
free_page on a random page, since the sidad field is aliased with the
gbea, which is not guaranteed to be zero.

This can happen, for example, if userspace calls the KVM_PV_DISABLE
IOCTL, and it fails, and then userspace calls the same IOCTL again.
This scenario is only possible if KVM has some serious bug or if the
hardware is broken.

The solution is to simply return successfully immediately if the vCPU
was already non secure.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Fixes: 19e1227768863a1469797c13ef8fea1af7beac2c ("KVM: S390: protvirt: Introduce instruction data area bounce buffer")
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-Id: <20210920132502.36111-3-imbrenda@linux.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
arch/s390/kvm/pv.c