]> git.itanic.dy.fi Git - linux-stable/commit
lib/stackdepot: off by one in depot_fetch_stack()
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 23 Feb 2024 14:20:13 +0000 (17:20 +0300)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:17:17 +0000 (18:17 -0400)
commit7f71a28b0a17ade767c8ff016433d89c4654d305
treefcfbec433efda640f7885d53d920dc3667cef579
parent533fabf94c2e90aeeff046c0b463e3ff2eadaf0a
lib/stackdepot: off by one in depot_fetch_stack()

[ Upstream commit dc24559472a682eb124e869cb110e7a2fd857322 ]

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: b29d31885814 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
lib/stackdepot.c