compat/memory: avoid UB shifts in XENMEM_exchange handling
PATCH 1/1 compat/memory: avoid UB shifts in XENMEM_exchange handling
Add an early basic check, yielding the same error code as the more thorough on the the main handler would produce.
Fixes b8a7efe8528a ("Enable compatibility mode operation for HYPERVISOR_memory_op")
Reported-by Manuel Andreas <[email protected]>
Signed-off-by Jan Beulich <[email protected]>
xen/common/compat/memory.c +5 -0
@@ -161,6 +161,11 @@ int compat_memory_op(unsigned int cmd, Xif (copy_from_guest (&cmp.xchg, arg,1 ) )return -EFAULT ; +/* Early coarse check, as max_order() isn't available here. */ +if ( cmp.xchg.in.extent_order >=BITS_PER_INT || + cmp.xchg.out.extent_order >=BITS_PER_INT ) +return -EPERM ; + order_delta = cmp.xchg.out.extent_order - cmp.xchg.in.extent_order;/* Various sanity checks. */ if ( (cmp.xchg.nr_exchanged > cmp.xchg.in.nr_extents) ||
Quoted 2 lines · Jan Beulich
Add an early basic check, yielding the same error code as the more thorough on the the main handler would produce.
"as the more thorough check in the main handler"...
Quoted 3 lines
Fixes b8a7efe8528a ("Enable compatibility mode operation for HYPERVISOR_memory_op")Reported-by Manuel Andreas <[email protected]>Signed-off-by Jan Beulich <[email protected]>
With that:
Reviewed-by Jason Andryuk <[email protected]>
Quoted 5 lines · Jason Andryuk
Quoted 2 lines · Jan Beulich
Add an early basic check, yielding the same error code as the more thorough on the the main handler would produce.
"as the more thorough check in the main handler"...
I had already correct the typo ("on" when "one" was meant).
Quoted 7 lines
Quoted 3 lines
Fixes b8a7efe8528a ("Enable compatibility mode operation for HYPERVISOR_memory_op")Reported-by Manuel Andreas <[email protected]>Signed-off-by Jan Beulich <[email protected]>With that:
Reviewed-by Jason Andryuk <[email protected]>
Thanks.
Jan
Quoted 6 lines · Jan Beulich
Add an early basic check, yielding the same error code as the more thorough on the the main handler would produce.
Fixes b8a7efe8528a ("Enable compatibility mode operation for HYPERVISOR_memory_op")Reported-by Manuel Andreas <[email protected]>Signed-off-by Jan Beulich <[email protected]>
Reviewed-by Andrew Cooper <[email protected]>