mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-13 22:50:26 +01:00
anv: Protect against OOB access to anv_state_pool::buckets
Suggested-by: Paulo Zanoni
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30751>
(cherry picked from commit 0921dfa044)
This commit is contained in:
parent
0f82e06741
commit
ee320276cd
2 changed files with 11 additions and 1 deletions
|
|
@ -54,7 +54,7 @@
|
|||
"description": "anv: Protect against OOB access to anv_state_pool::buckets",
|
||||
"nominated": true,
|
||||
"nomination_type": 0,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -777,6 +777,10 @@ anv_state_pool_return_blocks(struct anv_state_pool *pool,
|
|||
}
|
||||
|
||||
uint32_t block_bucket = anv_state_pool_get_bucket(block_size);
|
||||
|
||||
if (block_bucket >= ARRAY_SIZE(pool->buckets))
|
||||
return;
|
||||
|
||||
anv_free_list_push(&pool->buckets[block_bucket].free_list,
|
||||
&pool->table, st_idx, count);
|
||||
}
|
||||
|
|
@ -839,6 +843,9 @@ anv_state_pool_alloc_no_vg(struct anv_state_pool *pool,
|
|||
{
|
||||
uint32_t bucket = anv_state_pool_get_bucket(MAX2(size, align));
|
||||
|
||||
if (bucket >= ARRAY_SIZE(pool->buckets))
|
||||
return ANV_STATE_NULL;
|
||||
|
||||
struct anv_state *state;
|
||||
uint32_t alloc_size = anv_state_pool_get_bucket_size(bucket);
|
||||
int64_t offset;
|
||||
|
|
@ -949,6 +956,9 @@ anv_state_pool_free_no_vg(struct anv_state_pool *pool, struct anv_state state)
|
|||
|
||||
assert(state.offset >= pool->start_offset);
|
||||
|
||||
if (bucket >= ARRAY_SIZE(pool->buckets))
|
||||
return;
|
||||
|
||||
anv_free_list_push(&pool->buckets[bucket].free_list,
|
||||
&pool->table, state.idx, 1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue