From: Jan Beulich Date: Tue, 6 Apr 2021 14:17:42 +0000 (+0200) Subject: common: map_vcpu_info() cosmetics X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7ee7a3749bcb5d39ced5a1ee3e8284b2bb9abc29;p=people%2Fhx242%2Fxen.git common: map_vcpu_info() cosmetics Use ENXIO instead of EINVAL to cover the two cases of the address not satisfying the requirements. This will make an issue here better stand out at the call site. Also add a missing compat-mode related size check: If the sizes differed, other code in the function would need changing. Accompany this by a change to the initial sizeof() expression, tying it to the type of the variable we're actually after (matching e.g. the alignof() added by XSA-327). Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné Acked-by: Julien Grall --- diff --git a/xen/common/domain.c b/xen/common/domain.c index d85984638a..cdda0d1f29 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1427,17 +1427,18 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset) struct page_info *page; unsigned int align; - if ( offset > (PAGE_SIZE - sizeof(vcpu_info_t)) ) - return -EINVAL; + if ( offset > (PAGE_SIZE - sizeof(*new_info)) ) + return -ENXIO; #ifdef CONFIG_COMPAT + BUILD_BUG_ON(sizeof(*new_info) != sizeof(new_info->compat)); if ( has_32bit_shinfo(d) ) align = alignof(new_info->compat); else #endif align = alignof(*new_info); if ( offset & (align - 1) ) - return -EINVAL; + return -ENXIO; if ( !mfn_eq(v->vcpu_info_mfn, INVALID_MFN) ) return -EINVAL;