linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Suren Baghdasaryan <surenb@google.com>
To: Hugh Dickins <hughd@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	akpm@linux-foundation.org,  regressions@leemhuis.info,
	bagasdotme@gmail.com, jacobly.alt@gmail.com,
	 willy@infradead.org, liam.howlett@oracle.com, david@redhat.com,
	 peterx@redhat.com, ldufour@linux.ibm.com,
	linux-kernel@vger.kernel.org,  linux-mm@kvack.org,
	linuxppc-dev@lists.ozlabs.org,
	 linux-arm-kernel@lists.infradead.org,
	gregkh@linuxfoundation.org,  regressions@lists.linux.dev,
	stable@vger.kernel.org
Subject: Re: [PATCH] mm: lock newly mapped VMA with corrected ordering
Date: Sat, 8 Jul 2023 16:10:07 -0700	[thread overview]
Message-ID: <CAJuCfpGXC23r11-0jz+an01tO2BUOMpjJ93Dm3pc+EUQM=BXYg@mail.gmail.com> (raw)
In-Reply-To: <b5a5626-2684-899d-874b-801e7974b17@google.com>

On Sat, Jul 8, 2023 at 4:04 PM Hugh Dickins <hughd@google.com> wrote:
>
> Lockdep is certainly right to complain about
> (&vma->vm_lock->lock){++++}-{3:3}, at: vma_start_write+0x2d/0x3f
>                but task is already holding lock:
> (&mapping->i_mmap_rwsem){+.+.}-{3:3}, at: mmap_region+0x4dc/0x6db
> Invert those to the usual ordering.

Doh! Thanks Hugh!
I totally forgot to run this with lockdep enabled :(

>
> Fixes: 33313a747e81 ("mm: lock newly mapped VMA which can be modified after it becomes visible")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hugh Dickins <hughd@google.com>
> ---
>  mm/mmap.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 84c71431a527..3eda23c9ebe7 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2809,11 +2809,11 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
>         if (vma_iter_prealloc(&vmi))
>                 goto close_and_free_vma;
>
> +       /* Lock the VMA since it is modified after insertion into VMA tree */
> +       vma_start_write(vma);
>         if (vma->vm_file)
>                 i_mmap_lock_write(vma->vm_file->f_mapping);
>
> -       /* Lock the VMA since it is modified after insertion into VMA tree */
> -       vma_start_write(vma);
>         vma_iter_store(&vmi, vma);
>         mm->map_count++;
>         if (vma->vm_file) {
> --
> 2.35.3


  reply	other threads:[~2023-07-08 23:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-08 23:04 Hugh Dickins
2023-07-08 23:10 ` Suren Baghdasaryan [this message]
2023-07-08 23:22   ` Suren Baghdasaryan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJuCfpGXC23r11-0jz+an01tO2BUOMpjJ93Dm3pc+EUQM=BXYg@mail.gmail.com' \
    --to=surenb@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=bagasdotme@gmail.com \
    --cc=david@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hughd@google.com \
    --cc=jacobly.alt@gmail.com \
    --cc=ldufour@linux.ibm.com \
    --cc=liam.howlett@oracle.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=peterx@redhat.com \
    --cc=regressions@leemhuis.info \
    --cc=regressions@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox