[RFC PATCH v1.2 04/12] mm/damon/core: validate number of probes in valid_probe_params()
From: SJ Park
Date: Wed Jul 29 2026 - 10:26:29 EST
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 1b0f12d17de3a..07f4e7126397b 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1401,6 +1401,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;
if (!damon_has_probe_weights(ctx))
return true;
--
2.47.3