linux/mm/damon
SeongJae Park 6376a82459 mm/damon/core: make damon_start() waits until kdamond_fn() starts
The cleanup tasks of kdamond threads including reset of corresponding
DAMON context's ->kdamond field and decrease of global nr_running_ctxs
counter is supposed to be executed by kdamond_fn().  However, commit
0f91d13366 ("mm/damon: simplify stop mechanism") made neither
damon_start() nor damon_stop() ensure the corresponding kdamond has
started the execution of kdamond_fn().

As a result, the cleanup can be skipped if damon_stop() is called fast
enough after the previous damon_start().  Especially the skipped reset
of ->kdamond could cause a use-after-free.

Fix it by waiting for start of kdamond_fn() execution from
damon_start().

Link: https://lkml.kernel.org/r/20231208175018.63880-1-sj@kernel.org
Fixes: 0f91d13366 ("mm/damon: simplify stop mechanism")
Signed-off-by: SeongJae Park <sj@kernel.org>
Reported-by: Jakub Acs <acsjakub@amazon.de>
Cc: Changbin Du <changbin.du@intel.com>
Cc: Jakub Acs <acsjakub@amazon.de>
Cc: <stable@vger.kernel.org> # 5.15.x
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-12-12 17:20:17 -08:00
..
core-test.h mm/damon/core-test: fix memory leak in damon_new_ctx() 2023-10-04 10:32:32 -07:00
core.c mm/damon/core: make damon_start() waits until kdamond_fn() starts 2023-12-12 17:20:17 -08:00
dbgfs-test.h mm/damon/dbgfs-test: fix is_target_id() change 2022-03-22 15:57:12 -07:00
dbgfs.c mm/damon/core: implement scheme-specific apply interval 2023-10-04 10:32:31 -07:00
Kconfig mm/damon/sysfs-test: add a unit test for damon_sysfs_set_targets() 2023-10-25 16:47:15 -07:00
lru_sort.c mm/damon/lru_sort: avoid divide-by-zero in hot threshold calculation 2023-10-25 16:47:15 -07:00
Makefile mm/damon/modules: deduplicate init steps for DAMON context setup 2022-11-30 15:01:26 -08:00
modules-common.c mm/damon/modules: deduplicate init steps for DAMON context setup 2022-11-30 15:01:26 -08:00
modules-common.h mm/damon/modules: deduplicate init steps for DAMON context setup 2022-11-30 15:01:26 -08:00
ops-common.c mm/damon/ops-common: avoid divide-by-zero during region hotness calculation 2023-10-25 16:47:15 -07:00
ops-common.h mm/damon/ops-common: atomically test and clear young on ptes and pmds 2023-06-09 16:25:55 -07:00
paddr.c mm/damon/core: use pseudo-moving sum for nr_accesses_bp 2023-10-04 10:32:30 -07:00
reclaim.c mm/damon/core: implement scheme-specific apply interval 2023-10-04 10:32:31 -07:00
sysfs-common.c mm/damon/sysfs: make kobj_type structures constant 2023-02-09 16:51:45 -08:00
sysfs-common.h mm/damon/sysfs: avoid empty scheme tried regions for large apply interval 2023-10-18 14:34:19 -07:00
sysfs-schemes.c mm/damon/sysfs-schemes: add timeout for update_schemes_tried_regions 2023-12-06 16:12:48 -08:00
sysfs-test.h mm/damon/sysfs-test: add a unit test for damon_sysfs_set_targets() 2023-10-25 16:47:15 -07:00
sysfs.c mm/damon/sysfs: check error from damon_sysfs_update_target() 2023-11-15 15:30:09 -08:00
vaddr-test.h mm/damon/vaddr-test: fix memory leak in damon_do_test_apply_three_regions() 2023-09-29 17:20:47 -07:00
vaddr.c mm/damon/core: use pseudo-moving sum for nr_accesses_bp 2023-10-04 10:32:30 -07:00