* [RFC PATCH 0/5] mm/damon: unurgent fixes for infinite loop, NULL de-ref and races
@ 2026-07-11 18:04 SJ Park
2026-07-11 18:04 ` [RFC PATCH 2/5] mm/damon/tests/core-kunit: catch test failure in test_merge_regions_of() SJ Park
0 siblings, 1 reply; 2+ messages in thread
From: SJ Park @ 2026-07-11 18:04 UTC (permalink / raw)
Cc: SJ Park, # 5 . 15 . x, Andrew Morton, Brendan Higgins, David Gow,
Fernand Sieber, Leonard Foerster, SeongJae Park, Shakeel Butt,
damon, kunit-dev, linux-kernel, linux-kselftest, linux-mm
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.
SJ Park (5):
mm/damon/core: avoid infinite kdamond_merge_regions() internal loop
mm/damon/tests/core-kunit: catch test failure in
test_merge_regions_of()
mm/damon/vaddr: drop last same folio access check optimization
mm/damon/paddr: drop last same folio access check reuse optimization
mm/damon/sysfs: read ops_id only once
mm/damon/core.c | 13 +++++++++----
mm/damon/paddr.c | 20 ++++----------------
mm/damon/sysfs.c | 6 ++++--
mm/damon/tests/core-kunit.h | 3 +++
mm/damon/vaddr.c | 26 ++++----------------------
5 files changed, 24 insertions(+), 44 deletions(-)
base-commit: 65b3b6001701d46d5360097bdc90dfa1c06a1239
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* [RFC PATCH 2/5] mm/damon/tests/core-kunit: catch test failure in test_merge_regions_of()
2026-07-11 18:04 [RFC PATCH 0/5] mm/damon: unurgent fixes for infinite loop, NULL de-ref and races SJ Park
@ 2026-07-11 18:04 ` SJ Park
0 siblings, 0 replies; 2+ messages in thread
From: SJ Park @ 2026-07-11 18:04 UTC (permalink / raw)
Cc: SJ Park, # 5 . 15 . x, Andrew Morton, 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 68d30648c612e..fb882a0602ff9 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] 2+ messages in thread
end of thread, other threads:[~2026-07-11 18:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-11 18:04 [RFC PATCH 0/5] mm/damon: unurgent fixes for infinite loop, NULL de-ref and races SJ Park
2026-07-11 18:04 ` [RFC PATCH 2/5] mm/damon/tests/core-kunit: catch test failure in test_merge_regions_of() SJ Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox