From: Paul Durrant Date: Thu, 7 May 2015 13:08:43 +0000 (+0200) Subject: x86/hvm: use white-lists for HVM param guest accessibility checks X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~3324 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=30efda12d63ff536102ed8e580b4c09765683b44;p=xen.git x86/hvm: use white-lists for HVM param guest accessibility checks There are actually very few HVM parameters that a guest needs to read and even fewer that a guest needs to write. Use white-lists to specify those parameters and also ensre that, by default, newly introduced parameters are not accessible. Signed-off-by: Paul Durrant Reviewed-by: Andrew Cooper --- diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 6be1c7f9a9..371fd33ed3 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -5627,6 +5627,12 @@ static int hvm_allow_set_param(struct domain *d, switch ( a->index ) { + /* The following parameters can be set by the guest. */ + case HVM_PARAM_CALLBACK_IRQ: + case HVM_PARAM_VM86_TSS: + case HVM_PARAM_ACPI_IOPORTS_LOCATION: + case HVM_PARAM_VM_GENERATION_ID_ADDR: + break; /* * The following parameters must not be set by the guest * since the domain may need to be paused. @@ -5634,15 +5640,11 @@ static int hvm_allow_set_param(struct domain *d, case HVM_PARAM_IDENT_PT: case HVM_PARAM_DM_DOMAIN: case HVM_PARAM_ACPI_S_STATE: - /* The following parameters should not be set by the guest. */ - case HVM_PARAM_VIRIDIAN: - case HVM_PARAM_IOREQ_SERVER_PFN: - case HVM_PARAM_NR_IOREQ_SERVER_PAGES: + /* The remaining parameters should not be set by the guest. */ + default: if ( d == current->domain ) rc = -EPERM; break; - default: - break; } if ( rc ) @@ -5835,6 +5837,16 @@ static int hvm_allow_get_param(struct domain *d, switch ( a->index ) { + /* The following parameters can be read by the guest. */ + case HVM_PARAM_CALLBACK_IRQ: + case HVM_PARAM_VM86_TSS: + case HVM_PARAM_ACPI_IOPORTS_LOCATION: + case HVM_PARAM_VM_GENERATION_ID_ADDR: + case HVM_PARAM_STORE_PFN: + case HVM_PARAM_STORE_EVTCHN: + case HVM_PARAM_CONSOLE_PFN: + case HVM_PARAM_CONSOLE_EVTCHN: + break; /* * The following parameters must not be read by the guest * since the domain may need to be paused. @@ -5842,14 +5854,11 @@ static int hvm_allow_get_param(struct domain *d, case HVM_PARAM_IOREQ_PFN: case HVM_PARAM_BUFIOREQ_PFN: case HVM_PARAM_BUFIOREQ_EVTCHN: - /* The following parameters should not be read by the guest. */ - case HVM_PARAM_IOREQ_SERVER_PFN: - case HVM_PARAM_NR_IOREQ_SERVER_PAGES: + /* The remaining parameters should not be read by the guest. */ + default: if ( d == current->domain ) rc = -EPERM; break; - default: - break; } return rc;