Skip to content
Commit ec7b81b0 authored by SeongJae Park's avatar SeongJae Park Committed by Greg Kroah-Hartman
Browse files

mm/damon/core: make damon_start() waits until kdamond_fn() starts

commit 6376a824 upstream.

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
0f91d133 ("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: 0f91d133

 ("mm/damon: simplify stop mechanism")
Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
Reported-by: default avatarJakub Acs <acsjakub@amazon.de>
Cc: Changbin Du <changbin.du@intel.c...
parent 41f4ff9f
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment