Re: [PATCH] mm/damon/sysfs-schemes: fix use-after-free on memcg_path and goal path

From: junxi qian

Date: Wed Apr 22 2026 - 00:32:08 EST


Hi SJ,

Thank you for the suggestion and for offering to help.

It would be great if you could finish the remaining work. Please feel
free to add my Co-developed-by: and Signed-off-by: tags.

Thanks,
Junxi

On Wed, Apr 22, 2026 at 7:47 AM SeongJae Park <sj@xxxxxxxxxx> wrote:
>
> 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
>
> [...]