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:   Thu, 15 Mar 2018 07:45:21 +0000
From:   Ard Biesheuvel <ard.biesheuvel@...aro.org>
To:     Daniel Vacek <neelx@...hat.com>
Cc:     linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
        open list <linux-kernel@...r.kernel.org>,
        Mark Rutland <mark.rutland@....com>,
        Will Deacon <will.deacon@....com>,
        Catalin Marinas <catalin.marinas@....com>,
        Marc Zyngier <marc.zyngier@....com>,
        Mel Gorman <mgorman@...hsingularity.net>,
        Michal Hocko <mhocko@...e.com>,
        Paul Burton <paul.burton@...tec.com>,
        Pavel Tatashin <pasha.tatashin@...cle.com>,
        Vlastimil Babka <vbabka@...e.cz>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH v2] Revert "mm/page_alloc: fix memmap_init_zone pageblock alignment"

On 15 March 2018 at 07:44, Daniel Vacek <neelx@...hat.com> wrote:
> On Thu, Mar 15, 2018 at 8:36 AM, Ard Biesheuvel
> <ard.biesheuvel@...aro.org> wrote:
>> On 15 March 2018 at 02:23, Daniel Vacek <neelx@...hat.com> wrote:
>>> On Wed, Mar 14, 2018 at 8:29 PM, Ard Biesheuvel
>>> <ard.biesheuvel@...aro.org> wrote:
>>>> This reverts commit 864b75f9d6b0100bb24fdd9a20d156e7cda9b5ae.
>>>>
>>>> Commit 864b75f9d6b0 ("mm/page_alloc: fix memmap_init_zone pageblock
>>>> alignment") modified the logic in memmap_init_zone() to initialize
>>>> struct pages associated with invalid PFNs, to appease a VM_BUG_ON()
>>>> in move_freepages(), which is redundant by its own admission, and
>>>> dereferences struct page fields to obtain the zone without checking
>>>> whether the struct pages in question are valid to begin with.
>>>>
>>>> Commit 864b75f9d6b0 only makes it worse, since the rounding it does
>>>> may cause pfn assume the same value it had in a prior iteration of
>>>> the loop, resulting in an infinite loop and a hang very early in the
>>>> boot. Also, since it doesn't perform the same rounding on start_pfn
>>>> itself but only on intermediate values following an invalid PFN, we
>>>> may still hit the same VM_BUG_ON() as before.
>>>>
>>>> So instead, let's fix this at the core, and ensure that the BUG
>>>> check doesn't dereference struct page fields of invalid pages.
>>>>
>>>> Fixes: 864b75f9d6b0 ("mm/page_alloc: fix memmap_init_zone pageblock alignment")
>>>> Cc: Daniel Vacek <neelx@...hat.com>
>>>> Cc: Mel Gorman <mgorman@...hsingularity.net>
>>>> Cc: Michal Hocko <mhocko@...e.com>
>>>> Cc: Paul Burton <paul.burton@...tec.com>
>>>> Cc: Pavel Tatashin <pasha.tatashin@...cle.com>
>>>> Cc: Vlastimil Babka <vbabka@...e.cz>
>>>> Cc: Andrew Morton <akpm@...ux-foundation.org>
>>>> Cc: Linus Torvalds <torvalds@...ux-foundation.org>
>>>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@...aro.org>
>>>> ---
>>>>  mm/page_alloc.c | 13 +++++--------
>>>>  1 file changed, 5 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>>>> index 3d974cb2a1a1..635d7dd29d7f 100644
>>>> --- a/mm/page_alloc.c
>>>> +++ b/mm/page_alloc.c
>>>> @@ -1910,7 +1910,9 @@ static int move_freepages(struct zone *zone,
>>>>          * Remove at a later date when no bug reports exist related to
>>>>          * grouping pages by mobility
>>>>          */
>>>> -       VM_BUG_ON(page_zone(start_page) != page_zone(end_page));
>>>> +       VM_BUG_ON(pfn_valid(page_to_pfn(start_page)) &&
>>>> +                 pfn_valid(page_to_pfn(end_page)) &&
>>>> +                 page_zone(start_page) != page_zone(end_page));
>>>
>>> Hi, I am on vacation this week and I didn't have a chance to test this
>>> yet but I am not sure this is correct. Generic pfn_valid() unlike the
>>> arm{,64} arch specific versions returns true for all pfns in a section
>>> if there is at least some memory mapped in that section. So I doubt
>>> this prevents the crash I was targeting. I believe pfn_valid() does
>>> not change a thing here :(
>>>
>>
>> If this is the case, memblock_next_valid_pfn() is broken since it
>> skips valid PFNs, and we should be fixing that instead.
>
> How do you define valid pfn? Maybe the generic version of pfn_valid()
> should be fixed???
>

memblock_next_valid_pfn() skips PFNs for which pfn_valid() returns
true. That is clearly a bug.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ