Skip to content

mm/damon: move damos filter range arguments validation to core

SJ Park damon linux-kselftest linux-mm lkml stable 1 version Applied

Status from this message: [merged mm-stable] mm-damon-core-kunit-test-invalid-damos-filter-commits.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 2 repliesApplied 8/8

Changes from RFC v2 from the cover letter

- RFC v2: https://lore.kernel.org/[email protected]
- Drop RFC tag.
- Rebase to latest mm-new.
Changes from RFC
- RFC: https://lore.kernel.org/[email protected]
- Handle error from damos_commit_filter_arg() on all call sites.

Patches in v1 All 8 applied

#Subject and filesSizeRepliesApplied
1/8mm/damon/sysfs-schemes: read sysfs_filter->addr_range only oncemm/damon/sysfs-schemes.c+3 -30 repliesApplied
2/8mm/damon/sysfs-schemes: read sysfs_filter->sz_range only oncemm/damon/sysfs-schemes.c+3 -40 repliesApplied
3/8mm/damon/core: return an error from damos_commit_filter_arg()mm/damon/core.c+28 -130 repliesApplied
4/8mm/damon/core: disallow max < min damos filter range arguments commitmm/damon/core.c+6 -00 repliesApplied
5/8mm/damon/sysfs-schemes: drop centralized filter range arg validationsmm/damon/sysfs-schemes.c+0 -130 repliesApplied
6/8mm/damon/sysfs-schemes: use switch-case in add_scheme_filters()mm/damon/sysfs-schemes.c+13 -50 repliesApplied
7/8mm/damon/core-kunit: extend damos_commit_filter_for() for wrong inputmm/damon/tests/core-kunit.h+15 -90 repliesApplied
8/8mm/damon/core-kunit: test invalid damos filter commitsmm/damon/tests/core-kunit.h+14 -01 replyApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/8] mm/damon: move damos filter range arguments validation to core

DAMOS filter range arguments are being validated in the DAMON sysfs interface. Some of those have minor time-of-check to time-of-use (TOCTOU) bugs. In future, other callers might have duplicated validations with similar bugs.

Fix the bugs and further refactor the code to move the validation to the core layer. Also add kunit test cases for the validations.

Patches 1 and 2 fix the existing TOCTOU bugs. Patches 3 and 4 adds the validation in the core layer. Patch 5 drops the replicated validation in DAMON sysfs interface. Patch 6 further cleanup the code. Patches 7 and 8 extends kunit tests to test the validation.

Changes from RFC v2
- RFC v2: https://lore.kernel.org/[email protected]
- Drop RFC tag.
- Rebase to latest mm-new.
Changes from RFC
- RFC: https://lore.kernel.org/[email protected]
- Handle error from damos_commit_filter_arg() on all call sites.

SJ Park (8):
mm/damon/sysfs-schemes: read sysfs_filter->addr_range only once mm/damon/sysfs-schemes: read sysfs_filter->sz_range only once mm/damon/core: return an error from damos_commit_filter_arg() mm/damon/core: disallow max < min damos filter range arguments commit mm/damon/sysfs-schemes: drop centralized filter range arg validations mm/damon/sysfs-schemes: use switch-case in add_scheme_filters() mm/damon/core-kunit: extend damos_commit_filter_for() for wrong input mm/damon/core-kunit: test invalid damos filter commits

 mm/damon/core.c             | 47 +++++++++++++++++++++++++++----------
 mm/damon/sysfs-schemes.c    | 32 ++++++++++---------------
 mm/damon/tests/core-kunit.h | 38 +++++++++++++++++++++++-------
 3 files changed, 76 insertions(+), 41 deletions(-)

base-commit: 5e38c61dbb4349ff7e900d97d96f369c64678eea

Signature · 1 line
2.47.3