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: <1fc7ec3a-367c-eb9f-1cb4-b9e015fea87c@suse.cz>
Date:   Tue, 27 Oct 2020 12:05:21 +0100
From:   Vlastimil Babka <vbabka@...e.cz>
To:     David Hildenbrand <david@...hat.com>,
        Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Alexander Potapenko <glider@...gle.com>,
        Kees Cook <keescook@...omium.org>,
        Michal Hocko <mhocko@...nel.org>,
        Mateusz Nosek <mateusznosek0@...il.com>
Subject: Re: [PATCH 3/3] mm, page_alloc: reduce static keys in prep_new_page()

On 10/27/20 10:10 AM, David Hildenbrand wrote:
> On 26.10.20 18:33, Vlastimil Babka wrote:
>> prep_new_page() will always zero a new page (regardless of __GFP_ZERO) when
>> init_on_alloc is enabled, but will also always skip zeroing if the page was
>> already zeroed on free by init_on_free or page poisoning.
>> 
>> The latter check implemented by free_pages_prezeroed() can involve two
>> different static keys. As prep_new_page() is really a hot path, let's introduce
>> a single static key free_pages_not_prezeroed for this purpose and initialize it
>> in init_mem_debugging().
> 
> Is this actually observable in practice? This smells like
> micro-optimization to me.
> 
> Also, I thought the whole reason for static keys is to have basically no
> overhead at runtime, so I wonder if replacing two static key checks by a
> single one actually makes *some* difference.

You're right, the difference seems to be just a single NOP. The static key 
infrastructure seems to be working really well.
(At least the asm inspection made me realize that kernel_poison_pages() is 
called unconditionally and the static key is checked inside, not inline so I'll 
be amending patch 2...)

Initially I thought I would be reducing 3 keys to 1 in this patch, but I got the 
code wrong. So unless others think it's a readability improvements, we can drop 
this patch.

Or we can also reconsider this whole optimization. If the point is to be 
paranoid and enable both init_on_free and init_on_alloc, should we trust that 
nobody wrote something after the clearing on free via use-after-free? :) Kees/Alex?


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ