Re: [PATCH v2] mm/damon: validate min_region_size to be power of 2

SeongJae Park
2026-04-02T15:29:20Z

On Thu, 2 Apr 2026 07:03:14 -0700 SeongJae Park <sj@kernel.org> wrote:

> On Thu, 2 Apr 2026 13:37:56 +0800 Liew Rui Yan <aethernet65535@gmail.com> wrote:
>
> > Problem
> > =======
> > damon_commit_ctx() checks if 'min_region_sz' is a power of 2. But if it
> > is not, kdamond will terminate unexpectedly due to the user's invalid
> > input.
>
> Could you please further elaborate visible user impact of the problem and
> reproduction steps if available?
>
> >
> > Solution
> > ========
> > Add the same check to damon_{lru_sort, reclaim}_apply_parameters(), but
> > return -EINVAL immediately. This is to prevent user's invalid input
> > causing kdamond to terminate unexpectedly.
> >
> > This patch is a follow-up to the discussion in [1], where we agreed that
> > the validation should be done on min_region_sz rather than addr_unit.
> >
> > [1] https://lore.kernel.org/20260330233343.4083-1-sj@kernel.org
> >
>
> Should we add Fixes: and Cc: stable@ ?
>
> If we should Cc: stable@, and if the changes for DAMON_RECLAIM and
> DAMON_LRU_SORT deserve different Fixes:, I think this patch is better to be
> split into two patches, one for DAMON_RECLAIM, and the other for
> DAMON_LRU_SORT.
>
> > Signed-off-by: Liew Rui Yan <aethernet65535@gmail.com>
> > ---
> > Changes from v1:
> > - Fix memory leak issue.
> > - Link to v1: https://lore.kernel.org/20260331073231.30060-1-aethernet65535@gmail.com
>
> Seems you forgot the patch [1] before renaming of the subject.

Also, if you have posted RFCs or another different subject patches before,
please add full change log.

We are dealing with multiple patches in parallel, so I'm not fully following
entire contexts. Please understand.

>
> [...]
>
> The code changes look good to me.
>
> [1] https://lore.kernel.org/20260327062627.66426-1-aethernet65535@gmail.com

Thanks,
SJ …