Re: [PATCH] mm/damon/sysfs-schemes: fix use-after-free on memcg_path and goal path
From: SeongJae Park
Date: Tue Apr 21 2026 - 19:47:48 EST
On Tue, 21 Apr 2026 15:06:32 +0800 Junxi Qian <qjx1298677004@xxxxxxxxx> wrote:
> Hi SJ,
>
> Thanks for the suggestion.
>
> I checked the show/store race further and was able to reproduce the
> memcg_path_show() side issue on a KASAN kernel.
Thank you for sharing this, Jinxi!
[...]
> I will spend some time thinking about how to fix this properly.
>
> If someone more familiar with this code would like to work on the fix
> directly, that would be greatly appreciated, as I am not very familiar
> with this part of the code yet.
I think you could protect the memcg_path and path load/store() parts with the
damon_sysfs_lock, but using mutex_trylock() instead of mutex_lock(), as I
suggested. If you prefer me to finish the remaining work, please feel free to
let me know. If that's the case, I will work on the fix while adding
Co-developed-by: and Signed-off-by: tags of you on the fix, if you don't mind.
Thanks,
SJ
[...]