x86/HVM: fix PM timer I/O port range version check
PATCH 1/1 x86/HVM: fix PM timer I/O port range version check
XOR-ing two arbitrary non-equal values may produce 1 even if both values are different from both 0 and 1 (2 and 3 would fit, for example). Use OR instead, which together with the earlier bailing upon finding "version == old_version" achieves the intended effect.
xen/arch/x86/hvm/pmtimer.c +1 -1
@@ -326,7 +326,7 @@ int pmtimer_change_ioport(struct domainreturn 0 ;/* Only allow changes between versions 0 and 1. */ -if ( (version ^ old_version) !=1 ) +if ( (version | old_version) !=1 )return -EINVAL ;if ( version ==1 )
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · Jan Beulich
XOR-ing two arbitrary non-equal values may produce 1 even if both values are different from both 0 and 1 (2 and 3 would fit, for example). Use OR instead, which together with the earlier bailing upon finding "version ==
old_version" achieves the intended effect.Fixes f0ad21c499f7 ("x86 hvm: Introduce pmtimer_change_ioport and HVM_PARAM_ACPI_IOPORTS_LOCATION")Signed-off-by Jan Beulich <[email protected]>
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 10 lines · Roger Pau Monné
Quoted 7 lines · Jan Beulich
XOR-ing two arbitrary non-equal values may produce 1 even if both values are different from both 0 and 1 (2 and 3 would fit, for example). Use OR instead, which together with the earlier bailing upon finding "version ==
old_version" achieves the intended effect.Fixes f0ad21c499f7 ("x86 hvm: Introduce pmtimer_change_ioport and HVM_PARAM_ACPI_IOPORTS_LOCATION")Signed-off-by Jan Beulich <[email protected]>Reviewed-by Roger Pau Monné <[email protected]>
Thanks, but I withdraw this patch. The code is correct as is, just a little less obviously correct than with the use of |. As long as there's no way for the value stored in Xen to be larger than 1, there's also no way for a larger value to pass the check in question.
Instead I notice the upper 32 bits of the value are silently ignored. I'll submit a new patch addressing that instead.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel