* [PATCH] mm/damon/sysfs: skip registration if DAMON core init fails
@ 2026-11-23 7:51 Aveline Noir
2026-11-23 8:06 ` sashiko-bot
2026-11-23 15:36 ` SJ Park
0 siblings, 2 replies; 3+ messages in thread
From: Aveline Noir @ 2026-11-23 7:51 UTC (permalink / raw)
To: SJ Park, Andrew Morton; +Cc: Lian Wang, Dawei Li, damon, linux-mm
Hi SJ,
Here's the sysfs fix I mentioned in the report queue review.
-- >8 --
While reviewing the DAMON report queue series, I noticed that DAMON
sysfs still registers its interface if DAMON core initialization fails.
If damon_init() fails to allocate damon_region_cache, starting a
kdamond with an initial region can pass a NULL cache to
kmem_cache_alloc() via damon_new_region().
Check damon_initialized() before creating the DAMON sysfs directory and
return -ENOMEM if the core is unavailable.
Fixes: a18709442869 ("mm/damon: improve damon_new_region strategy")
Signed-off-by: Aveline Noir <jm5905938@gmail.com>
---
Tests passed in x86-64 QEMU TCG guests on 9f004372ebeb.
---
mm/damon/sysfs.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 779c98205a94..7de0f03a3fd5 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -3035,6 +3035,9 @@ static int __init damon_sysfs_init(void)
struct damon_sysfs_ui_dir *admin;
int err;
+ if (!damon_initialized())
+ return -ENOMEM;
+
damon_sysfs_root = kobject_create_and_add("damon", mm_kobj);
if (!damon_sysfs_root)
return -ENOMEM;
---
base-commit: 9f004372ebeb18fdeb699f9880a0e472df90135b
change-id: 20261123-damon-sysfs-init-guard-fc87e688acae
--
Thanks,
Aveline Noir
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] mm/damon/sysfs: skip registration if DAMON core init fails
2026-11-23 7:51 [PATCH] mm/damon/sysfs: skip registration if DAMON core init fails Aveline Noir
@ 2026-11-23 8:06 ` sashiko-bot
2026-11-23 15:36 ` SJ Park
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-23 8:06 UTC (permalink / raw)
To: Aveline Noir; +Cc: damon
> Hi SJ,
>
> Here's the sysfs fix I mentioned in the report queue review.
>
> -- >8 --
>
> While reviewing the DAMON report queue series, I noticed that DAMON
> sysfs still registers its interface if DAMON core initialization fails.
> If damon_init() fails to allocate damon_region_cache, starting a
> kdamond with an initial region can pass a NULL cache to
> kmem_cache_alloc() via damon_new_region().
>
> Check damon_initialized() before creating the DAMON sysfs directory and
> return -ENOMEM if the core is unavailable.
>
> Fixes: a18709442869 ("mm/damon: improve damon_new_region strategy")
> Signed-off-by: Aveline Noir <jm5905938@gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-damon-sysfs-init-guard-v1-1-a2a6ca65693a@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] mm/damon/sysfs: skip registration if DAMON core init fails
2026-11-23 7:51 [PATCH] mm/damon/sysfs: skip registration if DAMON core init fails Aveline Noir
2026-11-23 8:06 ` sashiko-bot
@ 2026-11-23 15:36 ` SJ Park
1 sibling, 0 replies; 3+ messages in thread
From: SJ Park @ 2026-11-23 15:36 UTC (permalink / raw)
To: Aveline Noir; +Cc: SJ Park, Andrew Morton, Lian Wang, Dawei Li, damon, linux-mm
On Mon, 23 Nov 2026 18:51:45 +1100 Aveline Noir <jm5905938@gmail.com> wrote:
> Hi SJ,
>
> Here's the sysfs fix I mentioned in the report queue review.
>
> -- >8 --
>
> While reviewing the DAMON report queue series, I noticed that DAMON
> sysfs still registers its interface if DAMON core initialization fails.
> If damon_init() fails to allocate damon_region_cache, starting a
> kdamond with an initial region can pass a NULL cache to
> kmem_cache_alloc() via damon_new_region().
"While reviewing ..." part seems unnecessary for git history. The user impact
(NULL dereference) could better be documented. What about below?
'''
DAMON sysfs registers ints interface even if DAMON core initialization fails.
If damon_init() fails to allocate damon_region_cache, starting a kdamond with
an initial region can pass a NULL cache to kmem_cache_alloc() via
damon_new_region(). As a result, NULL dereference can happen. The
initialization failure is unlikely, but the consequence is quite bad.
'''
>
> Check damon_initialized() before creating the DAMON sysfs directory and
> return -ENOMEM if the core is unavailable.
Thank you for finding and fixing the issue!
>
> Fixes: a18709442869 ("mm/damon: improve damon_new_region strategy")
> Signed-off-by: Aveline Noir <jm5905938@gmail.com>
Other than the above commit message,
Reviewed-by: SJ Park <sj@kernel.org>
With the above assumption, I applied this patch to damon/next [1] tree with the
commit message update. I will repost it soon (~1 week) as an mm.git merge
request. So, no action from your side is needed for now.
[1] https://origin.kernel.org/doc/html/latest/mm/damon/maintainer-profile.html#scm-trees
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-23 15:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 7:51 [PATCH] mm/damon/sysfs: skip registration if DAMON core init fails Aveline Noir
2026-11-23 8:06 ` sashiko-bot
2026-11-23 15:36 ` SJ Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox