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: <0a14f77f-2242-e3e3-611b-6d23fdf51756@huawei.com>
Date:   Thu, 2 Sep 2021 20:45:51 +0800
From:   Miaohe Lin <linmiaohe@...wei.com>
To:     David Hildenbrand <david@...hat.com>, <akpm@...ux-foundation.org>
CC:     <vbabka@...e.cz>, <sfr@...b.auug.org.au>, <peterz@...radead.org>,
        <mgorman@...hsingularity.net>, <linux-mm@...ck.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 5/5] mm/page_alloc.c: avoid allocating highmem pages
 via alloc_pages_exact[_nid]

On 2021/9/2 20:16, David Hildenbrand wrote:
> On 02.09.21 14:12, Miaohe Lin wrote:
>> Don't use with __GFP_HIGHMEM because page_address() cannot represent
>> highmem pages without kmap(). Newly allocated pages would leak as
>> page_address() will return NULL for highmem pages here. But It works
>> now because the callers do not specify __GFP_HIGHMEM now.
>>
>> Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
>> ---
>>   mm/page_alloc.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index 9c09dcb24149..e1d0e27d005a 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -5614,8 +5614,8 @@ void *alloc_pages_exact(size_t size, gfp_t gfp_mask)
>>       unsigned int order = get_order(size);
>>       unsigned long addr;
>>   -    if (WARN_ON_ONCE(gfp_mask & __GFP_COMP))
>> -        gfp_mask &= ~__GFP_COMP;
>> +    if (WARN_ON_ONCE(gfp_mask & (__GFP_COMP | __GFP_HIGHMEM)))
>> +        gfp_mask &= ~(__GFP_COMP | __GFP_HIGHMEM);
>>         addr = __get_free_pages(gfp_mask, order);
>>       return make_alloc_exact(addr, order, size);
>> @@ -5639,8 +5639,8 @@ void * __meminit alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask)
>>       unsigned int order = get_order(size);
>>       struct page *p;
>>   -    if (WARN_ON_ONCE(gfp_mask & __GFP_COMP))
>> -        gfp_mask &= ~__GFP_COMP;
>> +    if (WARN_ON_ONCE(gfp_mask & (__GFP_COMP | __GFP_HIGHMEM)))
>> +        gfp_mask &= ~(__GFP_COMP | __GFP_HIGHMEM);
>>         p = alloc_pages_node(nid, gfp_mask, order);
>>       if (!p)
>>
> 
> Ideally we would convert this WARN_ON_ONCE() to pr_warn_once(), but I guess this really never ever happens on a production system and would get caught early while testing.
> 

This patch is mainly intended to make it clear that we simply can't call
alloc_pages_exact[_nid] with GFP_HIGHMEM. So this warning would never ever happens.

> Reviewed-by: David Hildenbrand <david@...hat.com>
> 

Many thanks for your review and reply.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ