Re: [PATCH] avoid UB in guest handle arithmetic

2024-03-22 Thread Jan Beulich
On 22.03.2024 14:39, Stewart Hildebrand wrote: > On 3/19/24 09:26, Jan Beulich wrote: >> At least XENMEM_memory_exchange can have huge values passed in the >> nr_extents and nr_exchanged fields. Adding such values to pointers can >> overflow, resulting in UB. Cast respective pointers to "unsigned l

Re: [PATCH] avoid UB in guest handle arithmetic

2024-03-22 Thread Stewart Hildebrand
On 3/19/24 09:26, Jan Beulich wrote: > At least XENMEM_memory_exchange can have huge values passed in the > nr_extents and nr_exchanged fields. Adding such values to pointers can > overflow, resulting in UB. Cast respective pointers to "unsigned long" Why not uintptr_t?

[PATCH] avoid UB in guest handle arithmetic

2024-03-19 Thread Jan Beulich
At least XENMEM_memory_exchange can have huge values passed in the nr_extents and nr_exchanged fields. Adding such values to pointers can overflow, resulting in UB. Cast respective pointers to "unsigned long" while at the same time making the necessary multiplication explicit. Remaining arithmetic