The use in gnttab_map() is latently buggy, as "frames" there is
xen_pfn_t *, not unsigned long *. Adjust the correct use in
gnttab_map_frames_v2() as well, just to avoid the problematic pattern of
sizeof(<type>).
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -1406,7 +1406,7 @@ static int gnttab_map_frames_v2(xen_pfn_
/* No need for kzalloc as it is initialized in following hypercall
* GNTTABOP_get_status_frames.
*/
- sframes = kmalloc_array(nr_sframes, sizeof(uint64_t), GFP_ATOMIC);
+ sframes = kmalloc_array(nr_sframes, sizeof(*sframes), GFP_ATOMIC);
if (!sframes)
return -ENOMEM;
@@ -1478,7 +1478,7 @@ static int gnttab_map(unsigned int start
/* No need for kzalloc as it is initialized in following hypercall
* GNTTABOP_setup_table.
*/
- frames = kmalloc_array(nr_gframes, sizeof(unsigned long), GFP_ATOMIC);
+ frames = kmalloc_array(nr_gframes, sizeof(*frames), GFP_ATOMIC);
if (!frames)
return -ENOMEM;
On 30/07/2026 3:57 pm, Jan Beulich wrote: > The use in gnttab_map() is latently buggy, as "frames" there is > xen_pfn_t *, not unsigned long *. ARM32 has 64bit xen_pfn_t's. At least it's wrong in the safe direction. > Adjust the correct use in > gnttab_map_frames_v2() as well, just to avoid the problematic pattern of > sizeof(<type>). > > Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
On 30.07.2026 17:25, Andrew Cooper wrote: > On 30/07/2026 3:57 pm, Jan Beulich wrote: >> The use in gnttab_map() is latently buggy, as "frames" there is >> xen_pfn_t *, not unsigned long *. > > ARM32 has 64bit xen_pfn_t's. At least it's wrong in the safe direction. No, that alone would make it unsafe - we'd have allocated only half the size. What keeps the problem being latent is that the problem is on the PV-only path. >> Adjust the correct use in >> gnttab_map_frames_v2() as well, just to avoid the problematic pattern of >> sizeof(<type>). >> >> Signed-off-by: Jan Beulich <jbeulich@suse.com> > > Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Thanks. Jan
© 2016 - 2026 Red Hat, Inc.