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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9066e009-5ed2-1992-d70d-fd27b4bf5871@oracle.com>
Date:   Wed, 8 Jul 2020 10:45:16 -0700
From:   Mike Kravetz <mike.kravetz@...cle.com>
To:     Andrew Morton <akpm@...ux-foundation.org>,
        Barry Song <song.bao.hua@...ilicon.com>
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        linuxarm@...wei.com,
        Jonathan Cameron <jonathan.cameron@...wei.com>,
        Roman Gushchin <guro@...com>
Subject: Re: [PATCH v3] mm/hugetlb: avoid hardcoding while checking if cma is
 enable

On 7/7/20 12:56 PM, Andrew Morton wrote:
> On Tue, 7 Jul 2020 16:02:04 +1200 Barry Song <song.bao.hua@...ilicon.com> wrote:
> 
>> hugetlb_cma[0] can be NULL due to various reasons, for example, node0 has
>> no memory. so NULL hugetlb_cma[0] doesn't necessarily mean cma is not
>> enabled. gigantic pages might have been reserved on other nodes.
> 
> I'm trying to figure out whether this should be backported into 5.7.1,
> but the changelog doesn't describe any known user-visible effects of
> the bug.  Are there any?

Barry must have missed this email.  He reported the issue so I was hoping
he would reply.

Based on the code changes, I believe the following could happen:
- Someone uses 'hugetlb_cma=' kernel command line parameter to reserve
  CMA for gigantic pages.
- The system topology is such that no memory is on node 0.  Therefore,
  no CMA can be reserved for gigantic pages on node 0.  CMA is reserved
  on other nodes.
- The user also specifies a number of gigantic pages to pre-allocate on
  the command line with hugepagesz=<gigantic_page_size> hugepages=<N>
- The routine which allocates gigantic pages from the bootmem allocator
  will not detect CMA has been reserved as there is no memory on node 0.
  Therefore, pages will be pre-allocated from bootmem allocator as well
  as reserved in CMA.

This double allocation (bootmem and CMA) is the worst case scenario.  Not
sure if this is what Barry saw, and I suspect this would rarely happen.

After writing this, I started to think that perhaps command line parsing
should be changed.  If hugetlb_cma= is specified, it makes no sense to
pre-allocate gigantic pages.  Therefore, the hugepages=<N> paramemter
should be ignored and flagged with a warning if  hugetlb_cma= is specified.
This could be checked at parsing time and there would be no need for such
a check in the allocation code (except for sanity cheching).

Thoughts?  I just cleaned up the parsing code and could make such a change
quite easily.
-- 
Mike Kravetz

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ