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]
Date:   Tue, 6 Mar 2018 13:21:29 -0800
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Pavel Tatashin <pasha.tatashin@...cle.com>
Cc:     Steven Sistare <steven.sistare@...cle.com>,
        Daniel Jordan <daniel.m.jordan@...cle.com>,
        Masayoshi Mizuma <m.mizuma@...fujitsu.com>,
        Michal Hocko <mhocko@...e.com>,
        Catalin Marinas <catalin.marinas@....com>,
        AKASHI Takahiro <takahiro.akashi@...aro.org>,
        Gioh Kim <gi-oh.kim@...fitbricks.com>,
        Heiko Carstens <heiko.carstens@...ibm.com>,
        Yaowei Bai <baiyaowei@...s.chinamobile.com>,
        Wei Yang <richard.weiyang@...il.com>,
        Paul Burton <paul.burton@...s.com>,
        Miles Chen <miles.chen@...iatek.com>,
        Vlastimil Babka <vbabka@...e.cz>, Mel Gorman <mgorman@...e.de>,
        Johannes Weiner <hannes@...xchg.org>,
        LKML <linux-kernel@...r.kernel.org>, linux-mm@...ck.org
Subject: Re: [PATCH] mm: might_sleep warning

On Tue, 6 Mar 2018 16:04:06 -0500 Pavel Tatashin <pasha.tatashin@...cle.com> wrote:

> > > > >       spin_lock(&deferred_zone_grow_lock);
> > > > > -     static_branch_disable(&deferred_pages);
> > > > > +     deferred_zone_grow = false;
> > > > >       spin_unlock(&deferred_zone_grow_lock);
> > > > > +     static_branch_disable(&deferred_pages);
> > > > >
> > > > >       /* There will be num_node_state(N_MEMORY) threads */
> > > > >       atomic_set(&pgdat_init_n_undone, num_node_state(N_MEMORY));
> > > >
> > > > Kinda ugly, but I can see the logic behind the decisions.
> > > >
> > > > Can we instead turn deferred_zone_grow_lock into a mutex?
> >
> > (top-posting repaired.  Please don't top-post).
> >
> > > [CCed everyone]
> > >
> > > Hi Andrew,
> > >
> > > I afraid we cannot change this spinlock to mutex
> > > because deferred_grow_zone() might be called from an interrupt context if
> > > interrupt thread needs to allocate memory.
> > >
> >
> > OK.  But if deferred_grow_zone() can be called from interrupt then
> > page_alloc_init_late() should be using spin_lock_irq(), shouldn't it?
> > I'm surprised that lockdep didn't detect that.
> 
> No, page_alloc_init_late()  cannot be called from interrupt, it is
> called straight from:
> kernel_init_freeable(). But, I believe deferred_grow_zone(): can be called:
> 
> get_page_from_freelist()
>  _deferred_grow_zone()
>    deferred_grow_zone()

That's why page_alloc_init_late() needs spin_lock_irq().  If a CPU is
holding deferred_zone_grow_lock with enabled interrupts and an
interrupt comes in on that CPU and the CPU runs deferred_grow_zone() in
its interrupt handler, we deadlock.

lockdep knows about this bug and should have reported it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ