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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJuCfpEyE18kbH84FfmfzUnar2dxgzpi=FOYPbU8MOpz-SbVjg@mail.gmail.com>
Date:   Thu, 27 Jul 2023 10:22:42 -0700
From:   Suren Baghdasaryan <surenb@...gle.com>
To:     "Liam R. Howlett" <Liam.Howlett@...cle.com>,
        Suren Baghdasaryan <surenb@...gle.com>,
        akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, syzkaller-bugs@...glegroups.com,
        willy@...radead.org,
        syzbot <syzbot+8645fe63c4d22c8d27b8@...kaller.appspotmail.com>,
        Jann Horn <jannh@...gle.com>
Subject: Re: [syzbot] [mm?] WARNING: suspicious RCU usage in mas_walk (2)

On Thu, Jul 27, 2023 at 9:48 AM Liam R. Howlett <Liam.Howlett@...cle.com> wrote:
>
> * syzbot <syzbot+8645fe63c4d22c8d27b8@...kaller.appspotmail.com> [230726 02:57]:
> > syzbot has bisected this issue to:
> >
> > commit a52f58b34afe095ebc5823684eb264404dad6f7b
> > Author: Matthew Wilcox (Oracle) <willy@...radead.org>
> > Date:   Mon Jul 24 18:54:10 2023 +0000
> >
> >     mm: handle faults that merely update the accessed bit under the VMA lock
> >
> > bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=1783585ea80000
> > start commit:   [unknown]
> > git tree:       linux-next
> > final oops:     https://syzkaller.appspot.com/x/report.txt?x=1443585ea80000
> > console output: https://syzkaller.appspot.com/x/log.txt?x=1043585ea80000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=f481ab36ce878b84
> > dashboard link: https://syzkaller.appspot.com/bug?extid=8645fe63c4d22c8d27b8
> > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1697cec9a80000
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1566986ea80000
> >
> > Reported-by: syzbot+8645fe63c4d22c8d27b8@...kaller.appspotmail.com
> > Fixes: a52f58b34afe ("mm: handle faults that merely update the accessed bit under the VMA lock")
> >
> > For information about bisection process see: https://goo.gl/tpsmEJ#bisection
>
> This is caused by walking the maple tree without holding the mmap or rcu
> read lock when per-vma locking is used for the page fault.
>
> We could wrap the find_mergeable_anon_vma() walk with an rcu read lock,
> but I am unsure if that's the correct way to handle this as the anon_vma
> lock is taken later in __anon_vma_prepare().  Note that the anon_vma
> lock is per-anon_vma, so we cannot just relocate that lock.

Hmm. lock_vma_under_rcu() specifically checks for vma->anon_vma==NULL
condition (see [1]) to avoid going into find_mergeable_anon_vma() (a
check inside anon_vma_prepare() should prevent that). So, it should
fall back to mmap_lock'ing.
Jann Horn is fixing an issue with this check in [2] which happens
before we take the vma lock. So, it's possible that this race is
causing a call to find_mergeable_anon_vma() while holding per-VMA
lock. Another possibility is that the recent addition of vma_is_tcp()
is messing things up here... Either way, find_mergeable_anon_vma()
should never be called under per-VMA locks because it relies on
neighboring VMAs to be stable and we do not lock those.

[1] https://elixir.bootlin.com/linux/v6.5-rc3/source/mm/memory.c#L5396
[2] https://lore.kernel.org/all/20230726214103.3261108-3-jannh@google.com/


>
> I'm wondering if we need find_mergeable_anon_vma() to take a read lock
> on the VMA which contains the anon_vma to ensure it doesn't go away?
> Maybe a find_and_lock_mergeable_anon_vma() and return a locked anon_vma?
> Basically lock_vma_under_rcu(), anon_vma_lock_write(), vma_end_read().
>
> Thoughts?
>
> Thanks,
> Liam
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ