Skip to content

Commit ba1dd7a

Browse files
sjp38akpm00
authored andcommitted
mm/damon/sysfs-schemes: put damos dests dir after removing its files
damon_sysfs_scheme_rm_dirs() puts dests directory kobject before removing its internal files. Sincee putting the kobject frees its container struct, and the internal files removal accesses the container, use-after-free happens. Fix it by putting the reference _after_ removing the files. Link: https://lkml.kernel.org/r/20250816165559.2601-1-sj@kernel.org Fixes: 2cd0bf8 ("mm/damon/sysfs-schemes: implement DAMOS action destinations directory") Signed-off-by: SeongJae Park <sj@kernel.org> Reported-by: Alexandre Ghiti <alex@ghiti.fr> Closes: https://lore.kernel.org/2d39a734-320d-4341-8f8a-4019eec2dbf2@ghiti.fr Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 053c8eb commit ba1dd7a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

mm/damon/sysfs-schemes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2158,8 +2158,8 @@ static void damon_sysfs_scheme_rm_dirs(struct damon_sysfs_scheme *scheme)
21582158
{
21592159
damon_sysfs_access_pattern_rm_dirs(scheme->access_pattern);
21602160
kobject_put(&scheme->access_pattern->kobj);
2161-
kobject_put(&scheme->dests->kobj);
21622161
damos_sysfs_dests_rm_dirs(scheme->dests);
2162+
kobject_put(&scheme->dests->kobj);
21632163
damon_sysfs_quotas_rm_dirs(scheme->quotas);
21642164
kobject_put(&scheme->quotas->kobj);
21652165
kobject_put(&scheme->watermarks->kobj);

0 commit comments

Comments
 (0)