]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/damon/sysfs-schemes: put damos dests dir after removing its files
authorSeongJae Park <sj@kernel.org>
Sat, 16 Aug 2025 16:55:59 +0000 (09:55 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 19 Aug 2025 23:35:57 +0000 (16:35 -0700)
commitba1dd7ac735d604249f1e614d997dc66b30844ab
treee21952d55eae8abd8b78427163f95f509515e28b
parent053c8ebe74f7e1f4c072e59428da80b9d78bc4b7
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: 2cd0bf85a203 ("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>
mm/damon/sysfs-schemes.c