Skip to content

Commit fb497d6

Browse files
howlettakpm00
authored andcommitted
mm/damon/vaddr: protect vma traversal in __damon_va_thre_regions() with rcu read lock
Traversing VMAs of a given maple tree should be protected by rcu read lock. However, __damon_va_three_regions() is not doing the protection. Hold the lock. Link: https://lkml.kernel.org/r/[email protected] Fixes: d0cf3dd ("damon: convert __damon_va_three_regions to use the VMA iterator") Signed-off-by: Liam R. Howlett <[email protected]> Signed-off-by: SeongJae Park <[email protected]> Reported-by: Guenter Roeck <[email protected]> Closes: https://lore.kernel.org/[email protected] Tested-by: Guenter Roeck <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 0885ef4 commit fb497d6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mm/damon/vaddr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ static int __damon_va_three_regions(struct mm_struct *mm,
126126
* If this is too slow, it can be optimised to examine the maple
127127
* tree gaps.
128128
*/
129+
rcu_read_lock();
129130
for_each_vma(vmi, vma) {
130131
unsigned long gap;
131132

@@ -146,6 +147,7 @@ static int __damon_va_three_regions(struct mm_struct *mm,
146147
next:
147148
prev = vma;
148149
}
150+
rcu_read_unlock();
149151

150152
if (!sz_range(&second_gap) || !sz_range(&first_gap))
151153
return -EINVAL;

0 commit comments

Comments
 (0)