Skip to content

Commit

Permalink
mm/damon/core: initialize damo_filter->list from damos_new_filter()
Browse files Browse the repository at this point in the history
damos_new_filter() is not initializing the list field of newly allocated
filter object.  However, DAMON sysfs interface and DAMON_RECLAIM are not
initializing it after calling damos_new_filter().  As a result, accessing
uninitialized memory is possible.  Actually, adding multiple DAMOS filters
via DAMON sysfs interface caused NULL pointer dereferencing.  Initialize
the field just after the allocation from damos_new_filter().

Link: https://lkml.kernel.org/r/[email protected]
Fixes: 98def23 ("mm/damon/core: implement damos filter")
Signed-off-by: SeongJae Park <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
sjp38 authored and akpm00 committed Aug 4, 2023
1 parent f865474 commit 5f1fc67
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions mm/damon/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ struct damos_filter *damos_new_filter(enum damos_filter_type type,
return NULL;
filter->type = type;
filter->matching = matching;
INIT_LIST_HEAD(&filter->list);
return filter;
}

Expand Down

0 comments on commit 5f1fc67

Please sign in to comment.