* [PATCH] compat/memory: avoid UB shifts in XENMEM_exchange handling
@ 2025-04-17 14:08 Jan Beulich
2025-04-17 16:50 ` Jason Andryuk
2025-04-17 18:34 ` Andrew Cooper
0 siblings, 2 replies; 4+ messages in thread
From: Jan Beulich @ 2025-04-17 14:08 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné, Manuel Andreas
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 <manuel.andreas@tum.de>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/common/compat/memory.c
+++ b/xen/common/compat/memory.c
@@ -161,6 +161,11 @@ int compat_memory_op(unsigned int cmd, X
if ( 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) ||
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] compat/memory: avoid UB shifts in XENMEM_exchange handling
2025-04-17 14:08 [PATCH] compat/memory: avoid UB shifts in XENMEM_exchange handling Jan Beulich
@ 2025-04-17 16:50 ` Jason Andryuk
2025-04-22 6:23 ` Jan Beulich
2025-04-17 18:34 ` Andrew Cooper
1 sibling, 1 reply; 4+ messages in thread
From: Jason Andryuk @ 2025-04-17 16:50 UTC (permalink / raw)
To: Jan Beulich, xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné, Manuel Andreas
On 2025-04-17 10:08, Jan Beulich wrote:
> 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"...
> Fixes: b8a7efe8528a ("Enable compatibility mode operation for HYPERVISOR_memory_op")
> Reported-by: Manuel Andreas <manuel.andreas@tum.de>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
With that:
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] compat/memory: avoid UB shifts in XENMEM_exchange handling
2025-04-17 14:08 [PATCH] compat/memory: avoid UB shifts in XENMEM_exchange handling Jan Beulich
2025-04-17 16:50 ` Jason Andryuk
@ 2025-04-17 18:34 ` Andrew Cooper
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2025-04-17 18:34 UTC (permalink / raw)
To: Jan Beulich, xen-devel@lists.xenproject.org
Cc: Julien Grall, Stefano Stabellini, Anthony PERARD, Michal Orzel,
Roger Pau Monné, Manuel Andreas
On 17/04/2025 3:08 pm, Jan Beulich wrote:
> 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 <manuel.andreas@tum.de>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] compat/memory: avoid UB shifts in XENMEM_exchange handling
2025-04-17 16:50 ` Jason Andryuk
@ 2025-04-22 6:23 ` Jan Beulich
0 siblings, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2025-04-22 6:23 UTC (permalink / raw)
To: Jason Andryuk
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné, Manuel Andreas,
xen-devel@lists.xenproject.org
On 17.04.2025 18:50, Jason Andryuk wrote:
> On 2025-04-17 10:08, Jan Beulich wrote:
>> 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).
>> Fixes: b8a7efe8528a ("Enable compatibility mode operation for HYPERVISOR_memory_op")
>> Reported-by: Manuel Andreas <manuel.andreas@tum.de>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> With that:
>
> Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Thanks.
Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-22 6:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-17 14:08 [PATCH] compat/memory: avoid UB shifts in XENMEM_exchange handling Jan Beulich
2025-04-17 16:50 ` Jason Andryuk
2025-04-22 6:23 ` Jan Beulich
2025-04-17 18:34 ` Andrew Cooper
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.