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. 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 | 24 ++++++++++++++++------- mm/damon/sysfs-schemes.c | 32 +++++++++++++------------------ mm/damon/tests/core-kunit.h | 38 ++++++++++++++++++++++++++++--------- 3 files changed, 59 insertions(+), 35 deletions(-) base-commit: ec1b9fab95fbfd9c5dbdfb841d91929c2cb63518 -- 2.47.3

