Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,stable@vger.kernel.org,sj@kernel.org,
	set_pte_at@outlook.com,lienze@kylinos.cn,lianux.mm@gmail.com,
	jm5905938@gmail.com,akpm@linux-foundation.org
Subject: + mm-damon-sysfs-skip-registration-if-damon-core-init-fails.patch added to mm-hotfixes-unstable branch
Date: Mon, 30 Nov 2026 16:26:46 -0800	[thread overview]
Message-ID: <20261201002646.C674E1F00897@smtp.kernel.org> (raw)
In-Reply-To: <20261130150729.88226-1-sj@kernel.org>


The patch titled
     Subject: mm/damon/sysfs: skip registration if DAMON core init fails
has been added to the -mm mm-hotfixes-unstable branch.  Its filename is
     mm-damon-sysfs-skip-registration-if-damon-core-init-fails.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-damon-sysfs-skip-registration-if-damon-core-init-fails.patch

This patch will later appear in the mm-hotfixes-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: Aveline Noir <jm5905938@gmail.com>
Subject: mm/damon/sysfs: skip registration if DAMON core init fails
Date: Mon, 30 Nov 2026 07:07:28 -0800

DAMON sysfs registers its 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.

Link: https://patch.msgid.link/20261130150729.88226-1-sj@kernel.org
Fixes: a18709442869 ("mm/damon: improve damon_new_region strategy")
Signed-off-by: Aveline Noir <jm5905938@gmail.com>
Signed-off-by: SJ Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SJ Park <sj@kernel.org>
Tested-by: Enze Li <lienze@kylinos.cn>
Reviewed-by: Enze Li <lienze@kylinos.cn>
Cc: Lian Wang <lianux.mm@gmail.com>
Cc: Dawei Li <set_pte_at@outlook.com>
Cc: <stable@vger.kernel.org> # 6.1.x

 mm/damon/sysfs.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/mm/damon/sysfs.c~mm-damon-sysfs-skip-registration-if-damon-core-init-fails
+++ a/mm/damon/sysfs.c
@@ -3031,6 +3031,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;
_

Patches currently in -mm which might be from jm5905938@gmail.com are

mm-hmm-account-for-subpage-offsets-in-device-private-pmds.patch
mm-damon-sysfs-skip-registration-if-damon-core-init-fails.patch
mm-damon-ops-common-align-mmu-notifier-range-when-clearing-pmd-young-bit.patch
mm-damon-stat-avoid-32-bit-overflow-in-idle-percentiles.patch
mm-damon-pvaddr-skip-folios-already-on-the-migration-target-node.patch
docs-admin-guide-mm-damon-start-fix-grammar.patch
docs-admin-guide-mm-damon-stat-fix-pronoun-agreement.patch
docs-admin-guide-mm-damon-usage-fix-grammar.patch
docs-admin-guide-mm-damon-lru_sort-fix-remaining-grammar.patch
docs-mm-damon-design-fix-grammar-and-typos.patch
docs-mm-damon-api-fix-verb-form.patch
docs-mm-damon-maintainer-profile-fix-subject-verb-agreement.patch
docs-mm-damon-monitoring_intervals_tuning_example-fix-grammar-and-typos.patch
mm-damon-paddr-add-kunit-tests-for-addr_unit-conversion.patch
mm-damon-paddr-add-kunit-tests-for-addr_unit-conversion-fix.patch
mm-damon-paddr-skip-non-lru-folios-as-a-whole-in-pageout.patch
mm-damon-core-skip-apply_probes-when-no-probes-are-installed.patch
selftests-damon-damos_quota-skip-the-last-sample-when-counting-exceeds.patch


      reply	other threads:[~2026-12-01  0:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 15:07 [PATCH mm-hotfixes-unstable v2] mm/damon/sysfs: skip registration if DAMON core init fails SJ Park
2026-12-01  0:26 ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201002646.C674E1F00897@smtp.kernel.org \
    --to=akpm@linux-foundation.org \
    --cc=jm5905938@gmail.com \
    --cc=lianux.mm@gmail.com \
    --cc=lienze@kylinos.cn \
    --cc=mm-commits@vger.kernel.org \
    --cc=set_pte_at@outlook.com \
    --cc=sj@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox