From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [RFC PATCH v3 5/8] mm/damon/sysfs: support hugepage_size probe filter
Date: Tue, 15 Sep 2026 02:24:30 +0000 [thread overview]
Message-ID: <20260915022430.961FA1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260915020929.102953-6-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mm: partial commit failure in damon_commit_filter() causes DAMON context state corruption
--
commit bba894847aad85f23c968a2f306ec06c6e1b1a8c
Author: SJ Park <sj@kernel.org>
mm/damon/sysfs: support hugepage_size probe filter
Extend DAMON sysfs interface to support hugepage_size probe filter.
Allows hugepage_size user string input to the filter type file. Pass
the size range argument that users set via min/max files under the probe
filter directory to the DAMON core.
> diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
> index 8e8d89b8ed981..43519afb9eb7f 100644
> --- a/mm/damon/sysfs.c
> +++ b/mm/damon/sysfs.c
[ ... ]
> @@ -2273,6 +2277,9 @@ static int damon_sysfs_set_filters(struct damon_probe *probe,
> damon_destroy_filter(filter);
> return err;
> }
> + } else if (filter->type == DAMON_FILTER_TYPE_HUGEPAGE_SIZE) {
> + filter->range_min = sys_filter->range_min;
> + filter->range_max = sys_filter->range_max;
> }
[Severity: High]
Can an invalid hugepage_size range (where range_min > range_max) cause state
corruption in the DAMON context?
When a user configures a hugepage_size filter with range_min > range_max,
the values are copied blindly here into the intermediate context without
validation.
During the subsequent commit, damon_commit_filter() in mm/damon/core.c
updates the destination filter:
mm/damon/core.c:damon_commit_filter() {
dst->type = src->type;
dst->matching = src->matching;
dst->allow = src->allow;
switch (dst->type) {
case DAMON_FILTER_TYPE_MEMCG:
dst->memcg_id = src->memcg_id;
break;
case DAMON_FILTER_TYPE_HUGEPAGE_SIZE:
if (src->range_max < src->range_min)
return -EINVAL;
...
}
Because the validation fails and returns -EINVAL after dst->type,
dst->matching, and dst->allow have already been updated, the commit aborts
midway. This leaves the active DAMON context's filter partially mutated,
interpreting its previous union field (like memcg_id) as the new range
bounds.
Could validation be added to damon_sysfs_set_filters() in mm/damon/sysfs.c
to prevent invalid bounds from reaching the core commit logic?
> damon_add_filter(probe, filter);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260915020929.102953-1-sj@kernel.org?part=5
next prev parent reply other threads:[~2026-09-15 2:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 2:09 [RFC PATCH v3 0/8] mm/damon: introduce hugepage_size probe filter SJ Park
2026-09-15 2:09 ` [RFC PATCH v3 1/8] mm/damon/api: introduce DAMON_FILTER_TYPE_HUGEPAGE_SIZE SJ Park
2026-09-15 2:15 ` sashiko-bot
2026-09-15 2:09 ` [RFC PATCH v3 2/8] mm/damon/core: commit hugepage_size type damon filter SJ Park
2026-09-15 2:20 ` sashiko-bot
2026-09-15 2:09 ` [RFC PATCH v3 3/8] mm/damon/ops-common: support hugepage_size damon filter matching SJ Park
2026-09-15 2:22 ` sashiko-bot
2026-09-15 2:09 ` [RFC PATCH v3 4/8] mm/damon/sysfs: add min,max files under probe filter directory SJ Park
2026-09-15 2:14 ` sashiko-bot
2026-09-15 2:09 ` [RFC PATCH v3 5/8] mm/damon/sysfs: support hugepage_size probe filter SJ Park
2026-09-15 2:24 ` sashiko-bot [this message]
2026-09-15 2:29 ` SJ Park
2026-09-15 2:09 ` [RFC PATCH v3 6/8] Docs/mm/damon/design: update for " SJ Park
2026-09-15 2:11 ` sashiko-bot
2026-09-15 2:09 ` [RFC PATCH v3 7/8] Docs/admin-guide/mm/damon/usage: update for hugepage_size SJ Park
2026-09-15 2:12 ` sashiko-bot
2026-09-15 2:09 ` [RFC PATCH v3 8/8] Docs/ABI/damon: update for hugepage_size probe filter SJ Park
2026-09-15 2:24 ` sashiko-bot
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=20260915022430.961FA1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=damon@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sj@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