Skip to content

Commit 4f489fe

Browse files
sjp38akpm00
authored andcommitted
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. Link: https://lkml.kernel.org/r/[email protected] Fixes: 7ee161f ("mm/damon/sysfs-schemes: implement filter directory") Signed-off-by: SeongJae Park <[email protected]> Cc: Shuah Khan <[email protected]> Cc: <[email protected]> [6.3.x] Signed-off-by: Andrew Morton <[email protected]>
1 parent f576935 commit 4f489fe

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mm/damon/sysfs-schemes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ static ssize_t memcg_path_store(struct kobject *kobj,
472472
return -ENOMEM;
473473

474474
strscpy(path, buf, count + 1);
475+
kfree(filter->memcg_path);
475476
filter->memcg_path = path;
476477
return count;
477478
}

0 commit comments

Comments
 (0)