All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] mm/damon/sysfs: fix resource leak and NULL pointer dereferences
@ 2026-03-19 15:57 Josh Law
  2026-03-19 15:57 ` [PATCH 1/4] mm/damon/sysfs: fix param_ctx leak on damon_sysfs_new_test_ctx() failure Josh Law
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Josh Law @ 2026-03-19 15:57 UTC (permalink / raw)
  To: sj, akpm; +Cc: damon, linux-mm, linux-kernel, Josh Law

This series fixes a memory leak and three NULL pointer dereferences in
the DAMON sysfs interface, all in mm/damon/sysfs.c.

Patch 1 fixes a damon_ctx leak in damon_sysfs_commit_input() when
damon_sysfs_new_test_ctx() fails after param_ctx was already built.

Patches 2-4 fix missing contexts->nr checks before dereferencing
contexts_arr[0]. A user can trigger these by setting nr_contexts to 0
via sysfs and then issuing commands that assume a context exists:

  - Patch 2: CLEAR_SCHEMES_TRIED_REGIONS handler in damon_sysfs_handle_cmd()
  - Patch 3: damon_sysfs_update_schemes_tried_regions(), reached via
    UPDATE_SCHEMES_TRIED_BYTES and UPDATE_SCHEMES_TRIED_REGIONS
  - Patch 4: damon_sysfs_repeat_call_fn(), reachable when nr_contexts is
    set to 0 while DAMON is running

Josh Law (4):
  mm/damon/sysfs: fix param_ctx leak on damon_sysfs_new_test_ctx()
    failure
  mm/damon/sysfs: check contexts->nr before clear_schemes_tried_regions
  mm/damon/sysfs: check contexts->nr in update_schemes_tried_regions
  mm/damon/sysfs: check contexts->nr in repeat_call_fn

 mm/damon/sysfs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-03-20 15:56 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 15:57 [PATCH 0/4] mm/damon/sysfs: fix resource leak and NULL pointer dereferences Josh Law
2026-03-19 15:57 ` [PATCH 1/4] mm/damon/sysfs: fix param_ctx leak on damon_sysfs_new_test_ctx() failure Josh Law
2026-03-20  2:00   ` SeongJae Park
2026-03-19 15:57 ` [PATCH 2/4] mm/damon/sysfs: check contexts->nr before clear_schemes_tried_regions Josh Law
2026-03-20  2:13   ` SeongJae Park
2026-03-20  7:06     ` Josh Law
2026-03-20 14:47       ` SeongJae Park
2026-03-20 15:14         ` Josh Law
2026-03-20 15:51           ` SeongJae Park
2026-03-20 15:56             ` Josh Law
2026-03-19 15:57 ` [PATCH 3/4] mm/damon/sysfs: check contexts->nr in update_schemes_tried_regions Josh Law
2026-03-20  2:15   ` SeongJae Park
2026-03-19 15:57 ` [PATCH 4/4] mm/damon/sysfs: check contexts->nr in repeat_call_fn Josh Law
2026-03-20  2:06   ` SeongJae Park
2026-03-19 19:24 ` [PATCH 0/4] mm/damon/sysfs: fix resource leak and NULL pointer dereferences Josh Law

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.