lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJuCfpEyOXYh+dhW5iUFsz_s4P_pka9cD3M6qc8dDit5JxH3mw@mail.gmail.com>
Date:   Sat, 8 Jul 2023 16:22:56 -0700
From:   Suren Baghdasaryan <surenb@...gle.com>
To:     Hugh Dickins <hughd@...gle.com>
Cc:     Linus Torvalds <torvalds@...ux-foundation.org>,
        akpm@...ux-foundation.org, regressions@...mhuis.info,
        bagasdotme@...il.com, jacobly.alt@...il.com, willy@...radead.org,
        liam.howlett@...cle.com, david@...hat.com, peterx@...hat.com,
        ldufour@...ux.ibm.com, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, linuxppc-dev@...ts.ozlabs.org,
        linux-arm-kernel@...ts.infradead.org, gregkh@...uxfoundation.org,
        regressions@...ts.linux.dev, stable@...r.kernel.org
Subject: Re: [PATCH] mm: lock newly mapped VMA with corrected ordering

On Sat, Jul 8, 2023 at 4:10 PM Suren Baghdasaryan <surenb@...gle.com> wrote:
>
> On Sat, Jul 8, 2023 at 4:04 PM Hugh Dickins <hughd@...gle.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 :(

I verified both the lockdep warning and the fix. Thanks again, Hugh!

Tested-by: Suren Baghdasaryan <surenb@...gle.com>

>
> >
> > Fixes: 33313a747e81 ("mm: lock newly mapped VMA which can be modified after it becomes visible")
> > Cc: stable@...r.kernel.org
> > Signed-off-by: Hugh Dickins <hughd@...gle.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ