* [PATCH v1.1 2/6] mm/damon/tests/core-kunit: catch test failure in test_merge_regions_of()
2026-07-15 3:09 [PATCH v1.1 0/6] mm/damon: unurgent fixes for infinite loop, NULL de-ref and races SJ Park
@ 2026-07-15 3:09 ` SJ Park
2026-07-15 3:33 ` [PATCH v1.1 0/6] mm/damon: unurgent fixes for infinite loop, NULL de-ref and races SJ Park
2026-07-15 4:46 ` Andrew Morton
2 siblings, 0 replies; 5+ messages in thread
From: SJ Park @ 2026-07-15 3:09 UTC (permalink / raw)
To: Andrew Morton
Cc: SJ Park, stable, Brendan Higgins, David Gow, SeongJae Park, damon,
kunit-dev, linux-kernel, linux-kselftest, linux-mm
KUNIT_EXPECT_EQ() does not abort the execution of test code when the
expectation is not met. But damon_test_merge_regions_of() code after
its initial KUNIT_EXPECT_EQ() call assumes the expectation is met. It
does a per-region test with a hard-coded number of regions that is
correct only if the expectation was met. As a result, __nth_region_of()
could return NULL, and the test code can dereference NULL pointers. Fix
the issue by catching the expectation failure and skip the per-region
tests.
The user impact on realistic setups should be negligible, as it is a
unit test.
The issue was discovered [1] by Sashiko.
[1] https://lore.kernel.org/20260710144937.26981-1-sj@kernel.org
Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests")
Cc: <stable@vger.kernel.org> # 5.15.x
Signed-off-by: SJ Park <sj@kernel.org>
---
mm/damon/tests/core-kunit.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 485472ddebd19..eba643762132f 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -260,11 +260,14 @@ static void damon_test_merge_regions_of(struct kunit *test)
damon_merge_regions_of(t, 9, 9999, ctx, true);
/* 0-112, 114-130, 130-156, 156-170, 170-230, 230-10170 */
KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 6u);
+ if (damon_nr_regions(t) != 6)
+ goto out;
for (i = 0; i < 6; i++) {
r = __nth_region_of(t, i);
KUNIT_EXPECT_EQ(test, r->ar.start, saddrs[i]);
KUNIT_EXPECT_EQ(test, r->ar.end, eaddrs[i]);
}
+out:
damon_free_target(t);
damon_destroy_ctx(ctx);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v1.1 0/6] mm/damon: unurgent fixes for infinite loop, NULL de-ref and races
2026-07-15 3:09 [PATCH v1.1 0/6] mm/damon: unurgent fixes for infinite loop, NULL de-ref and races SJ Park
2026-07-15 3:09 ` [PATCH v1.1 2/6] mm/damon/tests/core-kunit: catch test failure in test_merge_regions_of() SJ Park
@ 2026-07-15 3:33 ` SJ Park
2026-07-15 4:46 ` Andrew Morton
2 siblings, 0 replies; 5+ messages in thread
From: SJ Park @ 2026-07-15 3:33 UTC (permalink / raw)
To: SJ Park
Cc: Andrew Morton, stable, Brendan Higgins, David Gow, Fernand Sieber,
Leonard Foerster, Quanmin Yan, SeongJae Park, Shakeel Butt, damon,
kunit-dev, linux-kernel, linux-kselftest, linux-mm
On Tue, 14 Jul 2026 20:09:55 -0700 SJ Park <sj@kernel.org> wrote:
> Sashiko found a few issues in DAMON that could cause infinite loop, NULL
> dereference and monitoring results degradation. The first two sounds
> scary but the infinite loop happens only under unreasonable user setup.
> The NULL dereference is only in a unit test. Monitoring results
> degradation is trivial since it is only best-effort, and those happens
> from only unlikely races. Still those are bugs that better to fix if
> possible. Fix those.
Sashiko found no blocker for this series. Sashiko sent findings to damon@
mailing list [1], and I replied to all the comments. Please read those for
details.
[1] https://lore.kernel.org/damon/
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1.1 0/6] mm/damon: unurgent fixes for infinite loop, NULL de-ref and races
2026-07-15 3:09 [PATCH v1.1 0/6] mm/damon: unurgent fixes for infinite loop, NULL de-ref and races SJ Park
2026-07-15 3:09 ` [PATCH v1.1 2/6] mm/damon/tests/core-kunit: catch test failure in test_merge_regions_of() SJ Park
2026-07-15 3:33 ` [PATCH v1.1 0/6] mm/damon: unurgent fixes for infinite loop, NULL de-ref and races SJ Park
@ 2026-07-15 4:46 ` Andrew Morton
2026-07-15 13:26 ` SJ Park
2 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2026-07-15 4:46 UTC (permalink / raw)
To: SJ Park
Cc: stable, Brendan Higgins, David Gow, Fernand Sieber,
Leonard Foerster, Quanmin Yan, SeongJae Park, Shakeel Butt, damon,
kunit-dev, linux-kernel, linux-kselftest, linux-mm
On Tue, 14 Jul 2026 20:09:55 -0700 SJ Park <sj@kernel.org> wrote:
> Sashiko found a few issues in DAMON that could cause infinite loop, NULL
> dereference and monitoring results degradation. The first two sounds
> scary but the infinite loop happens only under unreasonable user setup.
> The NULL dereference is only in a unit test. Monitoring results
> degradation is trivial since it is only best-effort, and those happens
> from only unlikely races. Still those are bugs that better to fix if
> possible. Fix those.
> Subject: [PATCH v1.1 0/6] ...
So... what is the significance of "1.1" here?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1.1 0/6] mm/damon: unurgent fixes for infinite loop, NULL de-ref and races
2026-07-15 4:46 ` Andrew Morton
@ 2026-07-15 13:26 ` SJ Park
0 siblings, 0 replies; 5+ messages in thread
From: SJ Park @ 2026-07-15 13:26 UTC (permalink / raw)
To: Andrew Morton
Cc: SJ Park, stable, Brendan Higgins, David Gow, Fernand Sieber,
Leonard Foerster, Quanmin Yan, SeongJae Park, Shakeel Butt, damon,
kunit-dev, linux-kernel, linux-kselftest, linux-mm
On Tue, 14 Jul 2026 21:46:04 -0700 Andrew Morton <akpm@linux-foundation.org> wrote:
> On Tue, 14 Jul 2026 20:09:55 -0700 SJ Park <sj@kernel.org> wrote:
>
> > Sashiko found a few issues in DAMON that could cause infinite loop, NULL
> > dereference and monitoring results degradation. The first two sounds
> > scary but the infinite loop happens only under unreasonable user setup.
> > The NULL dereference is only in a unit test. Monitoring results
> > degradation is trivial since it is only best-effort, and those happens
> > from only unlikely races. Still those are bugs that better to fix if
> > possible. Fix those.
>
> > Subject: [PATCH v1.1 0/6] ...
>
> So... what is the significance of "1.1" here?
As the changelog says, one more unurgent fix (patch 5 of this sereis) has added
on top of the v1.
Maybe my versioning scheme is confusing you. I increase minor version when it
is purely for findings from Sashiko and if the change seems not really big. I
do so because I realized it is easy to get version number large in short term
when I respect Sashiko, and it may look confusing for some people. Maybe a
better approach is running Sashiko in my local, but I don't have AI setup in my
development environment... Let me know if this only confuses and bothers you
and you have a suggestion.
Thanks,
SJ
^ permalink raw reply [flat|nested] 5+ messages in thread