diff mbox series

[v3] um: protect VMA iteration

Message ID 20221018124949.44384051d19a.I7b85b7dd326d2d078dabdd4ae40c35dc4ee1f3bc@changeid
State Accepted
Headers show
Series [v3] um: protect VMA iteration | expand

Commit Message

Johannes Berg Oct. 18, 2022, 10:49 a.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

Due to changes in the iteration, there are now lockdep
checks indicating that we're missing locking here. Add
the missing locking where it's needed.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
v2: use mmap_read_lock()
v3: umm, yeah I'm an idiot, tested without rebuilding
---
 arch/um/kernel/tlb.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Anton Ivanov Oct. 18, 2022, 12:02 p.m. UTC | #1
On 18/10/2022 11:49, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> Due to changes in the iteration, there are now lockdep
> checks indicating that we're missing locking here. Add
> the missing locking where it's needed.
> 
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
> v2: use mmap_read_lock()
> v3: umm, yeah I'm an idiot, tested without rebuilding

Happens even to the best of us.

> ---
>   arch/um/kernel/tlb.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c
> index ad449173a1a1..fa43bcd9ba0b 100644
> --- a/arch/um/kernel/tlb.c
> +++ b/arch/um/kernel/tlb.c
> @@ -597,6 +597,8 @@ void force_flush_all(void)
>   	struct vm_area_struct *vma;
>   	VMA_ITERATOR(vmi, mm, 0);
>   
> +	mmap_read_lock(mm);
>   	for_each_vma(vmi, vma)
>   		fix_range(mm, vma->vm_start, vma->vm_end, 1);
> +	mmap_read_unlock(mm);
>   }
Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>
diff mbox series

Patch

diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c
index ad449173a1a1..fa43bcd9ba0b 100644
--- a/arch/um/kernel/tlb.c
+++ b/arch/um/kernel/tlb.c
@@ -597,6 +597,8 @@  void force_flush_all(void)
 	struct vm_area_struct *vma;
 	VMA_ITERATOR(vmi, mm, 0);
 
+	mmap_read_lock(mm);
 	for_each_vma(vmi, vma)
 		fix_range(mm, vma->vm_start, vma->vm_end, 1);
+	mmap_read_unlock(mm);
 }