summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Kardashevskiy2018-05-14 12:00:29 +0200
committerPaul Mackerras2018-05-17 08:41:51 +0200
commite45719af1caff16dbc0f6bf7bbfbc5e7a54738a5 (patch)
tree9b49c718310ddc5d442a3c719c3541165a89253c
parentKVM: PPC: Book3S: Allow backing bigger guest IOMMU pages with smaller physica... (diff)
downloadkernel-qcow2-linux-e45719af1caff16dbc0f6bf7bbfbc5e7a54738a5.tar.gz
kernel-qcow2-linux-e45719af1caff16dbc0f6bf7bbfbc5e7a54738a5.tar.xz
kernel-qcow2-linux-e45719af1caff16dbc0f6bf7bbfbc5e7a54738a5.zip
KVM: PPC: Book3S: Check KVM_CREATE_SPAPR_TCE_64 parameters
Although it does not seem possible to break the host by passing bad parameters when creating a TCE table in KVM, it is still better to get an early clear indication of that than debugging weird effect this might bring. This adds some sanity checks that the page size is 4KB..16GB as this is what the actual LoPAPR supports and that the window actually fits 64bit space. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Acked-by: Balbir Singh <bsingharora@gmail.com> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
-rw-r--r--arch/powerpc/kvm/book3s_64_vio.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
index 984f1978a19c..80ead383d8ee 100644
--- a/arch/powerpc/kvm/book3s_64_vio.c
+++ b/arch/powerpc/kvm/book3s_64_vio.c
@@ -300,7 +300,8 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
int ret = -ENOMEM;
int i;
- if (!args->size)
+ if (!args->size || args->page_shift < 12 || args->page_shift > 34 ||
+ (args->offset + args->size > (ULLONG_MAX >> args->page_shift)))
return -EINVAL;
size = _ALIGN_UP(args->size, PAGE_SIZE >> 3);