Re: [PATCH 04/12] mm/damon/core: validate number of probes in valid_probe_params()
From: Kunwu Chan
Date: Wed Sep 02 2026 - 11:41:24 EST
On Tue, 1 Sep 2026 22:47:37 -0700 SJ Park <sj@xxxxxxxxxx> wrote:
> Each DAMON context is allowed to have only up to DAMON_MAX_PROBES
> probes. The central place for validating DAMON probe parameters,
> damon_valid_probe_params(), is not validating the upper limit, though.
> Do the validation.
>
> Signed-off-by: SJ Park <sj@xxxxxxxxxx>
> ---
> mm/damon/core.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 4d28eb033fc4a..c010f686d033e 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -1420,6 +1420,13 @@ static bool damon_valid_probe_params(struct damon_ctx *ctx)
> unsigned char max_probe_hits;
> struct damon_probe *probe;
> unsigned int wsum, wsum_to_add;
> + int nr_probes;
> +
> + nr_probes = 0;
> + damon_for_each_probe(probe, ctx)
> + nr_probes++;
> + if (nr_probes > DAMON_MAX_PROBES)
> + return false;
Hi SJ,
Thanks for the explanation.
I agree that `DAMON_MAX_PROBES` is better enforced in the core layer,
so that all callers share the same validation path without duplicating
the limit in the sysfs layer.
Reviewed-by: Kunwu Chan <kunwu.chan@xxxxxxxxx>
Thanks,
Kunwu
>
> if (!damon_has_probe_weights(ctx))
> return true;
> --
> 2.47.3
>
Sent using hkml (https://github.com/sjp38/hackermail)