From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH 6.18.y] mm/damon/core-kunit: handle region split failure in filter_out()
Date: Wed, 09 Sep 2026 04:15:34 +0000 [thread overview]
Message-ID: <20260909041534.EA6631F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260909040431.171803-1-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The exact same missing check for region split failure exists in `damon_test_split_at()`, leading to an out-of-bounds read.
--
commit fd822a4546c77b8ec92e7e67206ab99aafb176a1
Author: SJ Park <sj@kernel.org>
Subject: mm/damon/core-kunit: handle region split failure in filter_out()
The damos_test_filter_out() test checks if damos_filter_match() splits a
region as expected, but continued regardless of split successes. As a
result, the later part of the test could dereference invalid pointers
returned from damon_next_region() or corrupt memory from
damon_destroy_region(). This commit fixes it by exiting early when the
region split fails.
Link: https://lore.kernel.org/20260718001442.87129-5-sj@kernel.org
Link: https://lore.kernel.org/20260714142352.100478-1-sj@kernel.org [1]
> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index 6687778752728..801407b481cdc 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h
> @@ -588,6 +588,8 @@ static void damos_test_filter_out(struct kunit *test)
> KUNIT_EXPECT_EQ(test, r->ar.start, DAMON_MIN_REGION * 1);
> KUNIT_EXPECT_EQ(test, r->ar.end, DAMON_MIN_REGION * 2);
> KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 2);
> + if (damon_nr_regions(t) != 2)
> + goto out;
> r2 = damon_next_region(r);
[Severity: High]
This is a pre-existing issue, but since this patch fixes the missing split
verification here, should a similar check be added to damon_test_split_at() in
the same file?
In damon_test_split_at(), the code calls damon_split_region_at() and then
unconditionally accesses the next region:
damon_split_region_at(t, r, 25);
KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
KUNIT_EXPECT_EQ(test, r->ar.end, 25ul);
r_new = damon_next_region(r);
KUNIT_EXPECT_EQ(test, r_new->ar.start, 25ul);
If the split fails, r remains the only region in the list. Calling
damon_next_region(r) would then return an invalid pointer derived from the
list head. Dereferencing r_new->ar.start could cause an out-of-bounds read
and a potential kernel panic.
Does damon_test_split_at() need an early exit if the split fails to prevent
this memory corruption during testing?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909040431.171803-1-sj@kernel.org?part=1
prev parent reply other threads:[~2026-09-09 4:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2026090830-think-magical-cf80@gregkh>
2026-09-09 4:04 ` [PATCH 6.18.y] mm/damon/core-kunit: handle region split failure in filter_out() SJ Park
2026-09-09 4:15 ` sashiko-bot [this message]
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=20260909041534.EA6631F00A3A@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 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.