xen/dt-overlay: check overlay size before memcmp in tracker lookup

find_track_entry_from_tracker() compares overlay_fdt_size bytes of the
stored overlay against the input without verifying that the stored
overlay is at least that large. If the input is larger, memcmp reads
past the stored allocation. If smaller, a prefix match could falsely
succeed.

Compare fdt_totalsize() of the stored overlay against overlay_fdt_size
first. Both values are validated by check_overlay_fdt() at their
respective entry points, so no additional field in overlay_track is
needed.

Fixes: 7e5c4a8b86 ("xen/arm: Implement device tree node removal functionalities")
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
Michal Orzel committed 2026-04-29 07:37:58 +02:00
1 parent ca3f5e85aa
commit a7b7a50b33
1 file changed
+2 -1
+2 -1
View File
@@ -379,7 +379,8 @@ find_track_entry_from_tracker(const void *overlay_fdt,
*/
list_for_each_entry_safe( entry, temp, &overlay_tracker, entry )
{
if ( memcmp(entry->overlay_fdt, overlay_fdt, overlay_fdt_size) == 0 )
if ( (fdt_totalsize(entry->overlay_fdt) == overlay_fdt_size) &&
!memcmp(entry->overlay_fdt, overlay_fdt, overlay_fdt_size) )
{
found_entry = true;
break;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.