[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAG48ez0XCXoXbSR6dyX7GUQYJKRFKQsHuye5q-PLU3-gR5of5A@mail.gmail.com>
Date: Mon, 14 Aug 2023 16:54:01 +0200
From: Jann Horn <jannh@...gle.com>
To: akpm@...ux-foundation.org, Suren Baghdasaryan <surenb@...gle.com>
Cc: torvalds@...ux-foundation.org, willy@...radead.org,
liam.howlett@...cle.com, david@...hat.com, peterx@...hat.com,
ldufour@...ux.ibm.com, vbabka@...e.cz, michel@...pinasse.org,
jglisse@...gle.com, mhocko@...e.com, hannes@...xchg.org,
dave@...olabs.net, hughd@...gle.com, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, kernel-team@...roid.com
Subject: Re: [PATCH v4 5/6] mm: always lock new vma before inserting into vma tree
@akpm can you fix this up?
On Fri, Aug 4, 2023 at 5:27 PM Suren Baghdasaryan <surenb@...gle.com> wrote:
> While it's not strictly necessary to lock a newly created vma before
> adding it into the vma tree (as long as no further changes are performed
> to it), it seems like a good policy to lock it and prevent accidental
> changes after it becomes visible to the page faults. Lock the vma before
> adding it into the vma tree.
>
> Suggested-by: Jann Horn <jannh@...gle.com>
> Signed-off-by: Suren Baghdasaryan <surenb@...gle.com>
> Reviewed-by: Liam R. Howlett <Liam.Howlett@...cle.com>
> ---
> mm/mmap.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 3937479d0e07..850a39dee075 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -412,6 +412,8 @@ static int vma_link(struct mm_struct *mm, struct vm_area_struct *vma)
> if (vma_iter_prealloc(&vmi))
> return -ENOMEM;
>
> + vma_start_write(vma);
> +
> if (vma->vm_file) {
> mapping = vma->vm_file->f_mapping;
> i_mmap_lock_write(mapping);
Something went wrong when this part of the patch was applied, because
of a conflict with "mm/mmap: move vma operations to mm_struct out of
the critical section of file mapping lock"; see how this patch ended
up in the mm tree:
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/commit/?id=26cb4dafc13871ab68a4fb480ca1e19381cff392
> @@ -403,6 +403,8 @@ static int vma_link(struct mm_struct *mm, struct vm_area_struct *vma)
>
> vma_iter_store(&vmi, vma);
>
> + vma_start_write(vma);
> +
> if (vma->vm_file) {
> mapping = vma->vm_file->f_mapping;
> i_mmap_lock_write(mapping);
The "vma_start_write()" has to be ordered before the
"vma_iter_store(&vmi, vma)".
Powered by blists - more mailing lists