[igt-dev] [PATCH i-g-t 1/2] lib/intel_allocator_simple: Check boundaries of reserved blocks

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Wed Jul 28 16:54:24 UTC 2021


On Thu, Jul 22, 2021 at 10:24:25AM +0200, Andrzej Turko wrote:
> Make sure that reserved blocks fit in the
> address space managed by the simple allocator.
> 
> Signed-off-by: Andrzej Turko <andrzej.turko at linux.intel.com>
> Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> ---
>  lib/intel_allocator_simple.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/intel_allocator_simple.c b/lib/intel_allocator_simple.c
> index 0e6763964..8d5105f11 100644
> --- a/lib/intel_allocator_simple.c
> +++ b/lib/intel_allocator_simple.c
> @@ -523,6 +523,8 @@ static bool intel_allocator_simple_reserve(struct intel_allocator *ial,
>  	end = DECANONICAL(end);
>  	igt_assert(end > start || end == 0);
>  	size = get_size(start, end);
> +	igt_assert(start + size <= ials->end);
> +	igt_assert(start >= ials->start);

In the future I will likely have to relax get_size() and just do
end - start calculation (we're not passing i915 fd so we won't be able
to detect gtt size) but at the moment ok, we want to have this check.

So:

Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>

--
Zbigniew

>  
>  	if (simple_vma_heap_alloc_addr(ials, start, size)) {
>  		rec = malloc(sizeof(*rec));
> -- 
> 2.25.1
> 


More information about the igt-dev mailing list