Commit 6557004
mm/damon/sysfs: check contexts->nr in repeat_call_fn
damon_sysfs_repeat_call_fn() calls damon_sysfs_upd_tuned_intervals(),
damon_sysfs_upd_schemes_stats(), and
damon_sysfs_upd_schemes_effective_quotas() without checking contexts->nr.
If nr_contexts is set to 0 via sysfs while DAMON is running, these
functions dereference contexts_arr[0] and cause a NULL pointer
dereference. Add the missing check.
For example, the issue can be reproduced using DAMON sysfs interface and
DAMON user-space tool (damo) [1] like below.
$ sudo damo start --refresh_interval 1s
$ echo 0 | sudo tee \
/sys/kernel/mm/damon/admin/kdamonds/0/contexts/nr_contexts
Link: https://patch.msgid.link/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Link: https://github.com/damonitor/damo [1]
Fixes: d809a7c ("mm/damon/sysfs: implement refresh_ms file internal work")
Signed-off-by: Josh Law <[email protected]>
Reviewed-by: SeongJae Park <[email protected]>
Signed-off-by: SeongJae Park <[email protected]>
Cc: <[email protected]> [6.17+]
Signed-off-by: Andrew Morton <[email protected]>1 parent 1bfe9fb commit 6557004
1 file changed
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1620 | 1620 | | |
1621 | 1621 | | |
1622 | 1622 | | |
| 1623 | + | |
| 1624 | + | |
1623 | 1625 | | |
1624 | 1626 | | |
1625 | 1627 | | |
| 1628 | + | |
1626 | 1629 | | |
1627 | 1630 | | |
1628 | 1631 | | |
| |||
0 commit comments