mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
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:
1 parent
ca3f5e85aa
commit
a7b7a50b33
1 file changed
+2
-1
@@ -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;
|
||||
|
||||