From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [RFC PATCH 1/8] mm/damon/core: safely validate src on damon_commit_ctx()
Date: Wed, 01 Jul 2026 15:01:10 +0000 [thread overview]
Message-ID: <20260701150110.A4FB21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260701144815.113325-2-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Validation step incorrectly tests the existing context (`dst`) instead of the new parameters (`src`), completely neutralizing the patch's safety guarantees.
--
commit 4ac81fdba8a8c8576fad127fdd4347015f4dac51
Author: SJ Park <sj@kernel.org>
mm/damon/core: safely validate src on damon_commit_ctx()
This commit updates damon_commit_ctx() to validate parameters safely by
applying them to a test context before applying them to the running context.
If the test context validation succeeds, the real update proceeds.
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 5febe58a07028..5ca176eb27e1d 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
[ ... ]
> @@ -1635,6 +1622,52 @@ int damon_commit_ctx(struct damon_ctx *dst, struct damon_ctx *src)
[ ... ]
> +int damon_commit_ctx(struct damon_ctx *dst, struct damon_ctx *src)
> +{
> + struct damon_ctx *test_ctx;
> + int err;
> +
> + test_ctx = damon_new_test_ctx(dst);
> + if (!test_ctx)
> + return -ENOMEM;
> + err = __damon_commit_ctx(test_ctx, dst);
[Severity: High]
Does this code incorrectly validate the existing context instead of the new
parameters?
test_ctx is initialized as a clone of dst via damon_new_test_ctx(dst). If
__damon_commit_ctx() applies dst to test_ctx again, it avoids testing the
new parameters in src entirely.
If src contains invalid parameters (like a non-power-of-two min_region_sz),
it will bypass this check. When the unvalidated src is subsequently applied
to the running context:
err = __damon_commit_ctx(dst, src);
it can fail partway through. This leaves dst->maybe_corrupted = true and
causes the running kdamond monitoring thread to terminate unexpectedly.
Should the validation step be checking src instead?
err = __damon_commit_ctx(test_ctx, src);
> + if (err)
> + goto out;
> + err = __damon_commit_ctx(dst, src);
> +out:
> + damon_destroy_ctx(test_ctx);
> + return err;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260701144815.113325-1-sj@kernel.org?part=1
next prev parent reply other threads:[~2026-07-01 15:01 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 14:48 [RFC PATCH 0/8] mm/damon: validate all parameters in the core SJ Park
2026-07-01 14:48 ` [RFC PATCH 1/8] mm/damon/core: safely validate src on damon_commit_ctx() SJ Park
2026-07-01 15:01 ` sashiko-bot [this message]
2026-07-01 15:06 ` SJ Park
2026-07-01 14:48 ` [RFC PATCH 2/8] mm/damon/core: do parameter testing commit on damon_start() SJ Park
2026-07-01 15:20 ` sashiko-bot
2026-07-02 0:05 ` SJ Park
2026-07-01 14:48 ` [RFC PATCH 3/8] mm/damon/sysfs: remove duplicated commit input validity check SJ Park
2026-07-01 15:29 ` sashiko-bot
2026-07-02 0:09 ` SJ Park
2026-07-01 14:48 ` [RFC PATCH 4/8] mm/damon/reclaim: remove duplicated min_region_sz power of 2 check SJ Park
2026-07-01 15:42 ` sashiko-bot
2026-07-02 0:10 ` SJ Park
2026-07-01 14:48 ` [RFC PATCH 5/8] mm/damon/lru_sort: remove duplicated min_region_sz power_of_2() check SJ Park
2026-07-01 15:56 ` sashiko-bot
2026-07-02 0:15 ` SJ Park
2026-07-01 14:48 ` [RFC PATCH 6/8] mm/damon: document region size validation in damon_set_regions() SJ Park
2026-07-01 16:04 ` sashiko-bot
2026-07-02 0:16 ` SJ Park
2026-07-01 14:48 ` [RFC PATCH 7/8] mm/damon/core: remove start, end check in damon_set_region_system_rams() SJ Park
2026-07-01 16:22 ` sashiko-bot
2026-07-02 0:18 ` SJ Park
2026-07-01 14:48 ` [RFC PATCH 8/8] mm/damon/sysfs: remove region size validation SJ Park
2026-07-01 16:34 ` sashiko-bot
2026-07-02 0:19 ` 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=20260701150110.A4FB21F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=damon@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sj@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox