[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250619183608.6647-2-sj@kernel.org>
Date: Thu, 19 Jun 2025 11:36:07 -0700
From: SeongJae Park <sj@...nel.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: SeongJae Park <sj@...nel.org>, damon@...ts.linux.dev,
kernel-team@...a.com, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, stable@...r.kernel.org, #@....codeaurora.org,
6.3.x@....codeaurora.org
Subject: [PATCH 1/2] mm/damon/sysfs-schemes: free old damon_sysfs_scheme_filter->memcg_path on write
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.
Fixes: 7ee161f18b5d ("mm/damon/sysfs-schemes: implement filter directory")
Cc: stable@...r.kernel.org # 6.3.x
Signed-off-by: SeongJae Park <sj@...nel.org>
---
mm/damon/sysfs-schemes.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 0f6c9e1fec0b..30ae7518ffbf 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -472,6 +472,7 @@ static ssize_t memcg_path_store(struct kobject *kobj,
return -ENOMEM;
strscpy(path, buf, count + 1);
+ kfree(filter->memcg_path);
filter->memcg_path = path;
return count;
}
--
2.39.5
Powered by blists - more mailing lists