diff options
| author | SJ Park <sj@kernel.org> | 2026-09-14 07:23:18 -0700 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-10-12 21:26:07 -0700 |
| commit | 60e58be27d5e16d35e0728298f994dcae9f208a5 (patch) | |
| tree | 925fdfe5bb5ee15a8b7d3b779c76f9621b3e97cf /tools/perf/scripts/python | |
| parent | 3cada562c2bf0acbe505da23b705f125cb8ea119 (diff) | |
mm/damon/sysfs-schemes: read sysfs_filter->addr_range only once
Patch series "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.
This patch (of 8):
DAMON sysfs interface reads the user-provided address range arguments for
addr type DAMOS filter twice. Once for validation, and once again for
assignments to the variable that will be passed to the core layer. If the
user updates the argument in parallel, an invalid address range could be
passed to the core layer. Avoid it by doing the assignments first, and
then validating the assigned variables before passing those to the core
layer.
User impact of the bug should be trivial. From the core layer's
perspective, the invalid address range is not really invalid. It just
works as having a weird address range. No critical issues such as a crash
or a leak could happen. And sane users ain't do such parallel arguments
update anyway. If they do, such racy behavior is arguably somewhat
expected and deserved. That said, there is no reason to keep such races.
Link: https://lore.kernel.org/20260914142327.92510-1-sj@kernel.org
Link: https://lore.kernel.org/20260914142327.92510-2-sj@kernel.org
Fixes: 2f1abcfccd86 ("mm/damon/sysfs-schemes: support address range type DAMOS filter")
Signed-off-by: SJ Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@davidgow.net>
Cc: Usama Arif <usamaarif642@gmail.com>
Cc: <stable@vger.kernel.org>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
