From: SJ Park <sj@kernel.org>
To: sashiko-bot@kernel.org
Cc: SJ Park <sj@kernel.org>, damon@lists.linux.dev
Subject: Re: [PATCH 5/7] mm/damon/sysfs-schemes: support probe_hits_wsum damos core filter
Date: Thu, 10 Sep 2026 07:38:12 -0700 [thread overview]
Message-ID: <20260910143813.173904-1-sj@kernel.org> (raw)
In-Reply-To: <20260910143014.114E01F000FF@smtp.kernel.org>
On Thu, 10 Sep 2026 14:30:13 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] Time-of-Check to Time-of-Use race when validating probe_hits_wsum range allows invalid filter configurations to bypass validation.
> --
>
> commit 27bc99697c36a87c8e4b72fe6006955a564a4bb2
> Author: SJ Park <sj@kernel.org>
>
> mm/damon/sysfs-schemes: support probe_hits_wsum damos core filter
>
> Extend DAMON sysfs interface to support probe_hits_wsum input. Also
> update sysfs input based scheme build logic to setup the min/max probe
> hits weighted sum range as user provided.
>
> > diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> > index 4d9147d2a269e..d9dd4ee0442c7 100644
> > --- a/mm/damon/sysfs-schemes.c
> > +++ b/mm/damon/sysfs-schemes.c
>
> [ ... ]
>
> > @@ -2844,6 +2847,14 @@ static int damon_sysfs_add_scheme_filters(struct damos *scheme,
> > }
> > filter->sz_range.min = sysfs_filter->range_min;
> > filter->sz_range.max = sysfs_filter->range_max;
> > + } else if (filter->type == DAMOS_FILTER_TYPE_PROBE_HITS_WSUM) {
> > + if (sysfs_filter->range_min >
> > + sysfs_filter->range_max) {
> > + damos_destroy_filter(filter);
> > + return -EINVAL;
> > + }
> > + filter->range_min = sysfs_filter->range_min;
> > + filter->range_max = sysfs_filter->range_max;
>
> [Severity: Medium]
> Are these repeated reads of sysfs_filter->range_min and sysfs_filter->range_max
> susceptible to a time-of-check to time-of-use race?
>
> If a privileged user concurrently writes to a filter's min or max sysfs
> attribute between the validation check and the assignments:
>
> if (sysfs_filter->range_min > sysfs_filter->range_max) {
> // Validation passes
> }
>
> // Concurrent sysfs write updates range_min here
>
> filter->range_min = sysfs_filter->range_min; // Now invalid
>
> Could this allow an invalid configuration to bypass the check and be added to
> the DAMON scheme? Would it be safer to read the values into local variables
> first, validate those local variables, and then assign them to the filter?
Good finding, I agree this is better to be fixed. And maybe we could move the
validation to the core layer parameters validation logic.
I will fix this in the next revision.
>
> > }
> >
> > damos_add_filter(scheme, filter);
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260910141849.170896-1-sj@kernel.org?part=5
Thanks,
SJ
next prev parent reply other threads:[~2026-09-10 14:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 14:18 [PATCH 0/7] mm/damon: introduce probe_hits_wsum DAMOS core filter SJ Park
2026-09-10 14:18 ` [PATCH 1/7] mm/damon/api: introduce DAMOS_FILTER_TYPE_PROBE_HITS_WSUM SJ Park
2026-09-10 14:27 ` sashiko-bot
2026-09-10 14:32 ` SJ Park
2026-09-10 14:18 ` [PATCH 2/7] mm/damon/core: extend probe_hits_wsum() for moving sum based calculation SJ Park
2026-09-10 14:24 ` sashiko-bot
2026-09-10 14:18 ` [PATCH 3/7] mm/damon/core: support probe_hits_wsum damos core filter SJ Park
2026-09-10 14:26 ` sashiko-bot
2026-09-10 14:34 ` SJ Park
2026-09-10 14:18 ` [PATCH 4/7] mm/damon/sysfs-schemes: rename sysfs_filter->sz_range to range_{min,max} SJ Park
2026-09-10 14:27 ` sashiko-bot
2026-09-10 14:18 ` [PATCH 5/7] mm/damon/sysfs-schemes: support probe_hits_wsum damos core filter SJ Park
2026-09-10 14:30 ` sashiko-bot
2026-09-10 14:38 ` SJ Park [this message]
2026-09-10 14:18 ` [PATCH 6/7] Docs/mm/damon/design: update for probe_hits_wsum DAMOS " SJ Park
2026-09-10 14:24 ` sashiko-bot
2026-09-10 14:18 ` [PATCH 7/7] Docs/admin-guide/mm/damon/usage: update for probe_hits_wsum DAMOS filter SJ Park
2026-09-10 14:28 ` sashiko-bot
2026-09-10 14:40 ` [PATCH 0/7] mm/damon: introduce probe_hits_wsum DAMOS core filter 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=20260910143813.173904-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.