[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/5] xen/domain: Introduce a new check_domain_config() helper
Call it from the head of domain_create() (before doing any memory allocations), which will apply the checks to dom0 as well as domU's. For now, just subsume the XEN_DOMCTL_CDF_* check from XEN_DOMCTL_createdomain. This means that the corner case of the toolstack providing bad configuration will burn a domid, but production setups shouldn't ever get into this situation. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Wei Liu <wei.liu2@xxxxxxxxxx> CC: Stefano Stabellini <sstabellini@xxxxxxxxxx> CC: Julien Grall <julien.grall@xxxxxxx> --- xen/common/domain.c | 15 +++++++++++++++ xen/common/domctl.c | 9 --------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 65151e2..3f09a57 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -288,6 +288,18 @@ static void _domain_destroy(struct domain *d) free_domain_struct(d); } +static int check_domain_config(struct xen_domctl_createdomain *config) +{ + if ( config->flags & ~(XEN_DOMCTL_CDF_hvm_guest | + XEN_DOMCTL_CDF_hap | + XEN_DOMCTL_CDF_s3_integrity | + XEN_DOMCTL_CDF_oos_off | + XEN_DOMCTL_CDF_xs_domain) ) + return -EINVAL; + + return 0; +} + struct domain *domain_create(domid_t domid, struct xen_domctl_createdomain *config, bool is_priv) @@ -297,6 +309,9 @@ struct domain *domain_create(domid_t domid, INIT_evtchn = 1u<<3, INIT_gnttab = 1u<<4, INIT_arch = 1u<<5 }; int err, init_status = 0; + if ( config && (err = check_domain_config(config)) ) + return ERR_PTR(err); + if ( (d = alloc_domain_struct()) == NULL ) return ERR_PTR(-ENOMEM); diff --git a/xen/common/domctl.c b/xen/common/domctl.c index b294881..d08b627 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -498,15 +498,6 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) domid_t dom; static domid_t rover = 0; - ret = -EINVAL; - if ( (op->u.createdomain.flags & - ~(XEN_DOMCTL_CDF_hvm_guest - | XEN_DOMCTL_CDF_hap - | XEN_DOMCTL_CDF_s3_integrity - | XEN_DOMCTL_CDF_oos_off - | XEN_DOMCTL_CDF_xs_domain)) ) - break; - dom = op->domain; if ( (dom > 0) && (dom < DOMID_FIRST_RESERVED) ) { -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |