linux/arch/s390
Heiko Carstens 744b37fb5a s390/kvm,gaccess: fix guest access return code handling
Guest access functions like copy_to/from_guest() call __guestaddr_to_user()
which in turn call gmap_fault() in order to translate a guest address to a
user space address.
In error case __guest_addr_to_user() returns either -EFAULT or -ENOMEM.
The copy_to/from_guest functions just pass these return values down to the
callers.
The -ENOMEM case however is problematic since there are several places
which access guest memory like:

rc = copy_to_guest(...);
if (rc == -EFAULT)
	error_handling();

So in case of -ENOMEM the code assumes that the guest memory access
succeeded even though it failed.
This can cause guest data or state corruption.

If __guestaddr_to_user() returns -ENOMEM the meaning is that a valid user
space mapping exists, but there was not enough memory available when trying
to build the guest mapping. In other words an out-of-memory situation
occured.
For normal user space accesses an out-of-memory situation causes the page
fault handler to map -ENOMEM to -EFAULT (see fixup code in do_no_context()).
We need to do exactly the same for the kvm gaccess functions.

So __guestaddr_to_user() should just map all error codes to -EFAULT.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2013-03-07 16:21:19 -03:00
..
appldata s390/time: rename tod clock access functions 2013-02-14 15:55:10 +01:00
boot s390: fix linker script for 31 bit builds 2012-10-18 17:50:10 +02:00
crypto s390/crypto: Don't panic after crypto instruction failures 2012-11-23 11:14:27 +01:00
hypfs more file_inode() open-coded instances 2013-02-27 16:59:05 -05:00
include KVM: s390: Export virtio-ccw api. 2013-03-05 19:12:10 -03:00
kernel Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2013-03-03 12:58:43 -08:00
kvm s390/kvm,gaccess: fix guest access return code handling 2013-03-07 16:21:19 -03:00
lib s390/uaccess: fix kernel ds access for page table walk 2013-02-28 09:37:12 +01:00
math-emu s390/comments: unify copyright messages and remove file names 2012-07-20 11:15:04 +02:00
mm s390/mm: ignore change bit for vmemmap 2013-02-28 09:37:06 +01:00
net s390/bpf,jit: add vlan tag support 2013-02-14 15:55:20 +01:00
oprofile s390/irq: remove split irq fields from /proc/stat 2013-01-08 10:57:07 +01:00
pci hlist: drop the node parameter from iterators 2013-02-27 19:10:24 -08:00
defconfig s390: update defconfig 2012-09-26 15:45:29 +02:00
Kbuild s390/pci: base support 2012-11-30 15:40:45 +01:00
Kconfig arch Kconfig: centralise CONFIG_ARCH_NO_VIRT_TO_BUS 2013-02-27 19:10:23 -08:00
Kconfig.debug s390/mm: add page table dumper 2012-10-09 14:16:58 +02:00
Makefile s390: use -fPIC for module compile 2013-01-12 18:49:26 +01:00