public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* Fix prefix register checking in arch/s390/kvm/sigp.c
@ 2009-11-30 16:14 Carsten Otte
  2009-12-02 12:55 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Carsten Otte @ 2009-11-30 16:14 UTC (permalink / raw)
  To: Avi Kivity
  Cc: Alexander Graf, Heiko Carstens, KVM list, stable,
	Martin Schwidefsky

This patch corrects the checking of the new address for the prefix register.
On s390, the prefix register is used to address the cpu's lowcore (address
0...8k). This check is supposed to verify that the memory is readable and
present.
copy_from_guest is a helper function, that can be used to read from guest
memory. It applies prefixing, adds the start address of the guest memory in
user, and then calls copy_from_user. Previous code was obviously broken for
two reasons:
- prefixing should not be applied here. The current prefix register is
  going to be updated soon, and the address we're looking for will be
  0..8k after we've updated the register
- we're adding the guest origin (gmsor) twice: once in subject code
  and once in copy_from_guest

With kuli, we did not hit this problem because (a) we were lucky with
previous prefix register content, and (b) our guest memory was mmaped
very low into user address space.

This patch should go into 2.6.32, it prevents running smp guests with qemu.

Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Reported-by: Alexander Graf <agraf@suse.de>
---
 sigp.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Index: kvm/arch/s390/kvm/sigp.c
===================================================================
--- kvm.orig/arch/s390/kvm/sigp.c	2009-10-13 11:09:04.000000000 +0200
+++ kvm/arch/s390/kvm/sigp.c	2009-11-30 16:46:21.000000000 +0100
@@ -188,9 +188,9 @@
 
 	/* make sure that the new value is valid memory */
 	address = address & 0x7fffe000u;
-	if ((copy_from_guest(vcpu, &tmp,
-		(u64) (address + vcpu->arch.sie_block->gmsor) , 1)) ||
-	   (copy_from_guest(vcpu, &tmp, (u64) (address +
+	if ((copy_from_user(&tmp, (void __user *)
+		(address + vcpu->arch.sie_block->gmsor) , 1)) ||
+	   (copy_from_user(&tmp, (void __user *)(address +
 			vcpu->arch.sie_block->gmsor + PAGE_SIZE), 1))) {
 		*reg |= SIGP_STAT_INVALID_PARAMETER;
 		return 1; /* invalid parameter */

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

end of thread, other threads:[~2009-12-02 12:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-30 16:14 Fix prefix register checking in arch/s390/kvm/sigp.c Carsten Otte
2009-12-02 12:55 ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox