linux-stable/mm/damon
SeongJae Park ffe4a1ba1a mm/damon/dbgfs: fix 'struct pid' leaks in 'dbgfs_target_ids_write()'
commit ebb3f994dd upstream.

DAMON debugfs interface increases the reference counts of 'struct pid's
for targets from the 'target_ids' file write callback
('dbgfs_target_ids_write()'), but decreases the counts only in DAMON
monitoring termination callback ('dbgfs_before_terminate()').

Therefore, when 'target_ids' file is repeatedly written without DAMON
monitoring start/termination, the reference count is not decreased and
therefore memory for the 'struct pid' cannot be freed.  This commit
fixes this issue by decreasing the reference counts when 'target_ids' is
written.

Link: https://lkml.kernel.org/r/20211229124029.23348-1-sj@kernel.org
Fixes: 4bc05954d0 ("mm/damon: implement a debugfs-based user space interface")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org>	[5.15+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-01-05 12:42:39 +01:00
..
core-test.h mm/damon/core-test: fix wrong expectations for 'damon_split_regions_of()' 2021-10-28 17:18:55 -07:00
core.c mm/damon/core: fix fake load reports due to uninterruptible sleeps 2021-12-14 10:57:11 +01:00
dbgfs-test.h mm/damon: don't use strnlen() with known-bogus source length 2021-09-24 16:13:34 -07:00
dbgfs.c mm/damon/dbgfs: fix 'struct pid' leaks in 'dbgfs_target_ids_write()' 2022-01-05 12:42:39 +01:00
Kconfig mm/damon: add kunit tests 2021-09-08 11:50:25 -07:00
Makefile mm/damon: implement a debugfs-based user space interface 2021-09-08 11:50:24 -07:00
vaddr-test.h mm/damon: add kunit tests 2021-09-08 11:50:25 -07:00
vaddr.c mm/damon: add kunit tests 2021-09-08 11:50:25 -07:00