]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mm/damon/sysfs-schemes: free old damon_sysfs_scheme_filter->memcg_path on write
authorSeongJae Park <sj@kernel.org>
Thu, 19 Jun 2025 18:36:07 +0000 (11:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 6 Jul 2025 09:00:11 +0000 (11:00 +0200)
commit490a43d07f1663d827e802720d30cbc0494e4f81
treeccf029f2d1ef6861904506c9144b711b055c0b2a
parentc9036b6390afcd34c81cb64d3fb46a84c81abd4f
mm/damon/sysfs-schemes: free old damon_sysfs_scheme_filter->memcg_path on write

commit 4f489fe6afb395dbc79840efa3c05440b760d883 upstream.

memcg_path_store() assigns a newly allocated memory buffer to
filter->memcg_path, without deallocating the previously allocated and
assigned memory buffer.  As a result, users can leak kernel memory by
continuously writing a data to memcg_path DAMOS sysfs file.  Fix the leak
by deallocating the previously set memory buffer.

Link: https://lkml.kernel.org/r/20250619183608.6647-2-sj@kernel.org
Fixes: 7ee161f18b5d ("mm/damon/sysfs-schemes: implement filter directory")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: <stable@vger.kernel.org> [6.3.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/damon/sysfs-schemes.c