mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
lib/stackdepot: off by one in depot_fetch_stack()
The stack_pools[] array has DEPOT_MAX_POOLS. The "pools_num" tracks the
number of pools which are initialized. See depot_init_pool() for more
details.
If pool_index == pools_num_cached, this will read one element beyond what
we want. If not all the pools are initialized, then the pool will be
NULL, triggering a WARN(), and if they are all initialized it will read
one element beyond the end of the array.
Link: https://lkml.kernel.org/r/361ac881-60b7-471f-91e5-5bf8fe8042b2@moroto.mountain
Fixes: b29d318858
("lib/stackdepot: store free stack records in a freelist")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
9602e0ce98
commit
dc24559472
1 changed files with 1 additions and 1 deletions
|
@ -447,7 +447,7 @@ static struct stack_record *depot_fetch_stack(depot_stack_handle_t handle)
|
||||||
|
|
||||||
lockdep_assert_not_held(&pool_lock);
|
lockdep_assert_not_held(&pool_lock);
|
||||||
|
|
||||||
if (pool_index > pools_num_cached) {
|
if (pool_index >= pools_num_cached) {
|
||||||
WARN(1, "pool index %d out of bounds (%d) for stack id %08x\n",
|
WARN(1, "pool index %d out of bounds (%d) for stack id %08x\n",
|
||||||
pool_index, pools_num_cached, handle);
|
pool_index, pools_num_cached, handle);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue