From: SJ Park <sj@kernel.org>
To: sashiko-bot@kernel.org
Cc: SJ Park <sj@kernel.org>, damon@lists.linux.dev
Subject: Re: [RFC PATCH v1.1 5/8] mm/damon/lru_sort: remove duplicated min_region_sz power_of_2() check
Date: Thu, 2 Jul 2026 14:44:25 -0700 [thread overview]
Message-ID: <20260702214426.97100-1-sj@kernel.org> (raw)
In-Reply-To: <20260702212005.EF3901F000E9@smtp.kernel.org>
On Thu, 02 Jul 2026 21:20:05 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] Removing the early validation of `min_region_sz` causes persistent corruption of the `monitor_region_start` and `monitor_region_end` module parameters on failure.
> --
>
> commit 982a6b66f4f61086f3bd8de5a2da757081d4fa94
> Author: SJ Park <sj@kernel.org>
>
> mm/damon/lru_sort: remove duplicated min_region_sz power_of_2() check
>
> This commit removes an explicit power-of-two check on min_region_sz from
> damon_lru_sort_apply_parameters(), as the same validation is performed
> later in damon_commit_ctx().
>
> > diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
> > index 32f41491b726b..2dd0cd0d26273 100644
> > --- a/mm/damon/lru_sort.c
> > +++ b/mm/damon/lru_sort.c
> > @@ -284,11 +284,6 @@ static int damon_lru_sort_apply_parameters(void)
> > param_ctx->addr_unit = addr_unit;
> > param_ctx->min_region_sz = max(DAMON_MIN_REGION_SZ / addr_unit, 1);
> >
> > - if (!is_power_of_2(param_ctx->min_region_sz)) {
> > - err = -EINVAL;
> > - goto out;
> > - }
> > -
>
> [Severity: High]
> Does removing this early validation allow execution to proceed with an invalid
> addr_unit?
>
> If the monitor_region_start and monitor_region_end parameters are 0
> (the default, triggering auto-detection), they are overwritten in-place
> with system bounds scaled by the invalid addr_unit when this function
> is called later in damon_lru_sort_apply_parameters():
>
> err = damon_set_region_system_rams_default(param_target,
> &monitor_region_start,
> &monitor_region_end,
> param_ctx->addr_unit,
> param_ctx->min_region_sz);
>
> When damon_commit_ctx() later rejects the configuration and returns -EINVAL,
> these corrupted values are not reverted.
>
> If a user then corrects addr_unit and applies again, will the now non-zero
> parameters bypass auto-detection and get scaled again? This could cause
> DAMON to monitor an incorrect and massive physical address range, forcing
> the kdamond thread into a long pfn_valid() loop that consumes excessive CPU.
>
> Is the same state corruption possible in mm/damon/reclaim.c:
> damon_reclaim_apply_parameters() due to a similar removal of the early
> power-of-two check?
I think the user should recheck the parameters after failures. No blocker.
Thanks,
SJ
[...]
next prev parent reply other threads:[~2026-07-02 21:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 21:05 [RFC PATCH v1.1 0/8] mm/damon: validate all parameters in the core SJ Park
2026-07-02 21:05 ` [RFC PATCH v1.1 1/8] mm/damon/core: safely validate src on damon_commit_ctx() SJ Park
2026-07-02 21:21 ` sashiko-bot
2026-07-02 21:35 ` SJ Park
2026-07-02 21:05 ` [RFC PATCH v1.1 2/8] mm/damon/core: do parameter testing commit on damon_start() SJ Park
2026-07-02 21:05 ` [RFC PATCH v1.1 3/8] mm/damon/sysfs: remove duplicated commit input validity check SJ Park
2026-07-02 21:05 ` [RFC PATCH v1.1 4/8] mm/damon/reclaim: remove duplicated min_region_sz power of 2 check SJ Park
2026-07-02 21:05 ` [RFC PATCH v1.1 5/8] mm/damon/lru_sort: remove duplicated min_region_sz power_of_2() check SJ Park
2026-07-02 21:20 ` sashiko-bot
2026-07-02 21:44 ` SJ Park [this message]
2026-07-02 21:05 ` [RFC PATCH v1.1 6/8] mm/damon: document region size validation in damon_set_regions() SJ Park
2026-07-02 21:19 ` sashiko-bot
2026-07-02 21:48 ` SJ Park
2026-07-02 21:05 ` [RFC PATCH v1.1 7/8] mm/damon/core: remove start, end check in damon_set_region_system_rams() SJ Park
2026-07-02 21:16 ` sashiko-bot
2026-07-02 21:50 ` SJ Park
2026-07-02 21:05 ` [RFC PATCH v1.1 8/8] mm/damon/sysfs: remove region size validation SJ Park
2026-07-02 21:15 ` sashiko-bot
2026-07-02 21:53 ` SJ Park
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=20260702214426.97100-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=damon@lists.linux.dev \
--cc=sashiko-bot@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.