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.3 09/19] mm/damon/core: disallow probe_hits overflow on attrs only monitoring
Date: Thu, 9 Jul 2026 18:02:43 -0700 [thread overview]
Message-ID: <20260710010244.112723-1-sj@kernel.org> (raw)
In-Reply-To: <20260710004235.D59DC1F000E9@smtp.kernel.org>
On Fri, 10 Jul 2026 00:42:35 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] Missing validation in `damon_valid_probe_params()` fails to prevent a 32-bit integer overflow of the weighted sum of probe hits.
> --
>
> --- Patch [9]: [RFC PATCH v1.3 09/19] mm/damon/core: disallow probe_hits overflow on attrs only monitoring ---
> commit c184df8a3c8632af7a06675128fa4e375050fa8c
> Author: SJ Park <sj@kernel.org>
> Subject: mm/damon/core: disallow probe_hits overflow on attrs only monitoring
>
> This commit adds validation logic to prevent an 8-bit overflow of
> probe_hits when the aggregation interval is much larger than the
> sampling interval. It checks the parameters in a new function,
> damon_valid_probe_params().
>
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index 7d49420ea26c4..4f1425e56950b 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> [ ... ]
> > @@ -1332,6 +1332,19 @@ static void damos_set_filters_default_reject(struct damos *s)
> > damos_filters_default_reject(&s->ops_filters);
> > }
> >
> > +static bool damon_valid_probe_params(struct damon_ctx *ctx)
> > +{
> > + unsigned long sample_interval;
> > +
> > + if (!damon_has_probe_weights(ctx))
> > + return true;
> > +
> > + sample_interval = ctx->attrs.sample_interval ? : 1;
> > + if (ctx->attrs.aggr_interval / sample_interval > U8_MAX)
> > + return false;
> > + return true;
> > +}
>
> [Severity: Medium]
> Since we are adding validation for the 8-bit probe_hits overflow here,
> should we also validate that the 32-bit weighted sum of probe hits doesn't
> overflow?
>
> If a DAMON context is configured with probes where probe->weight is large
> enough, probe->weight * max_probe_hits (up to 255) could exceed UINT_MAX, or
> their cumulative sum could overflow. This would result in an incorrect score
> being returned by damon_probe_hits_wsum(), causing improper region merges in
> damon_merge_regions_of() and degrading monitoring accuracy.
>
> While damon_has_probe_weights() currently returns false making this path
> unreachable, would it be safer to add the weighted sum overflow check now to
> prevent issues when probe weights are fully implemented?
That's exactly what the next patch of this series is doing.
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260710002349.111414-1-sj@kernel.org?part=9
Thanks,
SJ
next prev parent reply other threads:[~2026-07-10 1:02 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 0:23 [RFC PATCH v1.3 00/19] mm/damon: introduce data attributes only monitoring SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 01/19] mm/damon/core: introduce damon_probe->weight SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 02/19] mm/damon/core: ask apply_probes() ops callback to set sampling address SJ Park
2026-07-10 0:33 ` sashiko-bot
2026-07-10 1:01 ` SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 03/19] mm/damon/paddr: set samples in apply_probes() if requested SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 04/19] mm/damon/core: ask apply_probe() to return max probe hits weighted sum SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 05/19] mm/damon/core: implement damon_probe_hits_wsum() SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 06/19] mm/damon/paddr: respect return_max_wsum SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 07/19] mm/damon/core: use abs_diff() instead of abs() SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 08/19] mm/damon/core: extend merge function to work with probe hits SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 09/19] mm/damon/core: disallow probe_hits overflow on attrs only monitoring SJ Park
2026-07-10 0:42 ` sashiko-bot
2026-07-10 1:02 ` SJ Park [this message]
2026-07-10 0:23 ` [RFC PATCH v1.3 10/19] mm/damon/core: validate params for probe hits weighted sum overflow SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 11/19] mm/damon/core: disable access monitoring when probe weights are set SJ Park
2026-07-10 0:43 ` sashiko-bot
2026-07-10 1:08 ` SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 12/19] mm/damon/core: set samples in apply_probes() if " SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 13/19] mm/damon/core: s/max_nr_accesses/max_merge_score/ in kdamond_fn() SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 14/19] mm/damon/core: get merge threshold from probe hits when weights are set SJ Park
2026-07-10 0:38 ` sashiko-bot
2026-07-10 1:10 ` SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 15/19] mm/damon/core: implement damon_has_probe_weight() SJ Park
2026-07-10 0:46 ` sashiko-bot
2026-07-10 1:18 ` SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 16/19] mm/damon/sysfs: implement probe/weight file SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 17/19] Docs/mm/damon/design: document attrs-only monitoring SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 18/19] Docs/admin-guide/mm/damon/usage: document weight sysfs file SJ Park
2026-07-10 0:23 ` [RFC PATCH v1.3 19/19] Docs/ABI/damon: document probe weight file 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=20260710010244.112723-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.