DAMON development mailing list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [RFC PATCH 5/8] mm/damon/sysfs: support hugepage_size probe filter
Date: Sun, 13 Sep 2026 17:30:22 +0000	[thread overview]
Message-ID: <20260913173023.394EF1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260913171133.102366-6-sj@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Medium] Missing bounds validation for hugepage_size filter in damon_sysfs_set_filters().

Pre-existing issues:
- [High] Newly created hugepage_size filters lack range bounds initialization in damon_commit_filters(), causing the DAMON core to evaluate folios against uninitialized kernel heap memory.
--

commit 42f3666a978b5b2934ebb23daaee8fd5163c7793
Author: SJ Park <sj@kernel.org>
Subject: mm/damon/sysfs: support hugepage_size probe filter

This commit extends the DAMON sysfs interface to support the hugepage_size
probe filter. It allows users to set hugepage_size via sysfs min/max files
and passes these arguments 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: Medium]
Are bounds checks needed here to ensure range_min is less than or equal to
range_max?

Because DAMON's initial startup via damon_start() bypasses the bounds check
in damon_commit_filter(), turning DAMON on with inverted bounds in sysfs
silently accepts the configuration. The filter then unconditionally fails to
match any folios, resulting in a silent functional failure instead of an
expected -EINVAL rejection.

[Severity: High]
This isn't a bug introduced by this patch, but I noticed that newly created
hugepage_size filters lack range bounds initialization in
damon_commit_filters().

If a user configures a new hugepage_size filter via sysfs on an already
running DAMON context and writes 'commit' to the state file, the newly
added filter is allocated without initializing the range:

mm/damon/core.c:damon_commit_filters() {
...
		new_filter = damon_new_filter(src_filter->type,
				src_filter->matching, src_filter->allow);
		if (!new_filter)
			return -ENOMEM;
		switch (src_filter->type) {
		case DAMON_FILTER_TYPE_MEMCG:
			new_filter->memcg_id = src_filter->memcg_id;
			break;
		default:
			break;
		}
...
}

Because damon_new_filter() allocates memory without zeroing, and the switch
statement explicitly omits DAMON_FILTER_TYPE_HUGEPAGE_SIZE, range_min and
range_max are populated with uninitialized kernel heap memory. Could this
cause the DAMON core to evaluate folios against erratic heap garbage?

> +		}
>  		damon_add_filter(probe, filter);
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260913171133.102366-1-sj@kernel.org?part=5

  reply	other threads:[~2026-09-13 17:30 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-13 17:11 [RFC PATCH 0/8] mm/damon: introduce hugepage_size probe filter SJ Park
2026-09-13 17:11 ` [RFC PATCH 1/8] mm/damon/api: introduce DAMON_FILTER_TYPE_HUGEPAGE_SIZE SJ Park
2026-09-13 17:22   ` sashiko-bot
2026-09-13 17:31     ` SJ Park
2026-09-13 17:40       ` SJ Park
2026-09-13 17:11 ` [RFC PATCH 2/8] mm/damon/core: commit hugepage_size type damon filter SJ Park
2026-09-13 17:24   ` sashiko-bot
2026-09-13 17:33     ` SJ Park
2026-09-13 17:41       ` SJ Park
2026-09-13 17:11 ` [RFC PATCH 3/8] mm/damon/ops-common: support hugepage_size damon filter matching SJ Park
2026-09-13 17:24   ` sashiko-bot
2026-09-13 17:35     ` SJ Park
2026-09-13 17:41       ` SJ Park
2026-09-13 17:11 ` [RFC PATCH 4/8] mm/damon/sysfs: add min,max files under probe filter directory SJ Park
2026-09-13 17:16   ` sashiko-bot
2026-09-13 17:11 ` [RFC PATCH 5/8] mm/damon/sysfs: support hugepage_size probe filter SJ Park
2026-09-13 17:30   ` sashiko-bot [this message]
2026-09-13 17:38     ` SJ Park
2026-09-13 17:11 ` [RFC PATCH 6/8] Docs/mm/damon/design: update for " SJ Park
2026-09-13 17:24   ` sashiko-bot
2026-09-13 17:42     ` SJ Park
2026-09-13 17:11 ` [RFC PATCH 7/8] Docs/admin-guide/mm/damon/usage: update for hugepage_size SJ Park
2026-09-13 17:13   ` sashiko-bot
2026-09-13 17:11 ` [RFC PATCH 8/8] Docs/ABI/damon: update for hugepage_size probe filter SJ Park
2026-09-13 17:13   ` 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=20260913173023.394EF1F000FF@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