* [PATCH v5 1/7] mm: Restore init_on_* static branch defaults [not found] <20210309214301.678739-1-keescook@chromium.org> @ 2021-03-09 21:42 ` Kees Cook 2021-03-10 23:56 ` Andrew Morton 0 siblings, 1 reply; 3+ messages in thread From: Kees Cook @ 2021-03-09 21:42 UTC (permalink / raw) To: Thomas Gleixner Cc: Kees Cook, stable, Elena Reshetova, x86, Andy Lutomirski, Peter Zijlstra, Catalin Marinas, Will Deacon, Mark Rutland, Alexander Potapenko, Alexander Popov, Ard Biesheuvel, Jann Horn, kernel-hardening, linux-hardening, linux-arm-kernel, linux-mm, linux-kernel, Vlastimil Babka, David Hildenbrand, Mike Rapoport, Andrew Morton, Jonathan Corbet, Randy Dunlap Choosing the initial state of static branches changes the assembly layout (if the condition is expected to be likely, inline, or unlikely, out of line via a jump). The _TRUE/_FALSE defines for CONFIG_INIT_ON_*_DEFAULT_ON were accidentally removed. These need to stay so that the CONFIG controls the pessimization of the resulting static branch NOP/JMP locations. Fixes: 04013513cc84 ("mm, page_alloc: do not rely on the order of page_poison and init_on_alloc/free parameters") Cc: stable@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> --- include/linux/mm.h | 8 ++++++++ mm/page_alloc.c | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 77e64e3eac80..b3317d91ee8e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2871,7 +2871,11 @@ static inline void kernel_poison_pages(struct page *page, int numpages) { } static inline void kernel_unpoison_pages(struct page *page, int numpages) { } #endif +#ifdef CONFIG_INIT_ON_ALLOC_DEFAULT_ON +DECLARE_STATIC_KEY_TRUE(init_on_alloc); +#else DECLARE_STATIC_KEY_FALSE(init_on_alloc); +#endif static inline bool want_init_on_alloc(gfp_t flags) { if (static_branch_unlikely(&init_on_alloc)) @@ -2879,7 +2883,11 @@ static inline bool want_init_on_alloc(gfp_t flags) return flags & __GFP_ZERO; } +#ifdef CONFIG_INIT_ON_FREE_DEFAULT_ON +DECLARE_STATIC_KEY_TRUE(init_on_free); +#else DECLARE_STATIC_KEY_FALSE(init_on_free); +#endif static inline bool want_init_on_free(void) { return static_branch_unlikely(&init_on_free); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3e4b29ee2b1e..f2d474a844cf 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -167,10 +167,18 @@ unsigned long totalcma_pages __read_mostly; int percpu_pagelist_fraction; gfp_t gfp_allowed_mask __read_mostly = GFP_BOOT_MASK; +#ifdef CONFIG_INIT_ON_ALLOC_DEFAULT_ON +DEFINE_STATIC_KEY_TRUE(init_on_alloc); +#else DEFINE_STATIC_KEY_FALSE(init_on_alloc); +#endif EXPORT_SYMBOL(init_on_alloc); +#ifdef CONFIG_INIT_ON_FREE_DEFAULT_ON +DEFINE_STATIC_KEY_TRUE(init_on_free); +#else DEFINE_STATIC_KEY_FALSE(init_on_free); +#endif EXPORT_SYMBOL(init_on_free); static bool _init_on_alloc_enabled_early __read_mostly -- 2.25.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v5 1/7] mm: Restore init_on_* static branch defaults 2021-03-09 21:42 ` [PATCH v5 1/7] mm: Restore init_on_* static branch defaults Kees Cook @ 2021-03-10 23:56 ` Andrew Morton 2021-03-15 17:28 ` Kees Cook 0 siblings, 1 reply; 3+ messages in thread From: Andrew Morton @ 2021-03-10 23:56 UTC (permalink / raw) To: Kees Cook Cc: Thomas Gleixner, stable, Elena Reshetova, x86, Andy Lutomirski, Peter Zijlstra, Catalin Marinas, Will Deacon, Mark Rutland, Alexander Potapenko, Alexander Popov, Ard Biesheuvel, Jann Horn, kernel-hardening, linux-hardening, linux-arm-kernel, linux-mm, linux-kernel, Vlastimil Babka, David Hildenbrand, Mike Rapoport, Jonathan Corbet, Randy Dunlap On Tue, 9 Mar 2021 13:42:55 -0800 Kees Cook <keescook@chromium.org> wrote: > Choosing the initial state of static branches changes the assembly layout > (if the condition is expected to be likely, inline, or unlikely, out of > line via a jump). The _TRUE/_FALSE defines for CONFIG_INIT_ON_*_DEFAULT_ON > were accidentally removed. These need to stay so that the CONFIG controls > the pessimization of the resulting static branch NOP/JMP locations. Changelog doesn't really explain why anyone would want to apply this patch. This is especially important for -stable patches. IOW, what is the user visible effect of the bug? ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v5 1/7] mm: Restore init_on_* static branch defaults 2021-03-10 23:56 ` Andrew Morton @ 2021-03-15 17:28 ` Kees Cook 0 siblings, 0 replies; 3+ messages in thread From: Kees Cook @ 2021-03-15 17:28 UTC (permalink / raw) To: Andrew Morton Cc: Thomas Gleixner, stable, Elena Reshetova, x86, Andy Lutomirski, Peter Zijlstra, Catalin Marinas, Will Deacon, Mark Rutland, Alexander Potapenko, Alexander Popov, Ard Biesheuvel, Jann Horn, kernel-hardening, linux-hardening, linux-arm-kernel, linux-mm, linux-kernel, Vlastimil Babka, David Hildenbrand, Mike Rapoport, Jonathan Corbet, Randy Dunlap On Wed, Mar 10, 2021 at 03:56:02PM -0800, Andrew Morton wrote: > On Tue, 9 Mar 2021 13:42:55 -0800 Kees Cook <keescook@chromium.org> wrote: > > > Choosing the initial state of static branches changes the assembly layout > > (if the condition is expected to be likely, inline, or unlikely, out of > > line via a jump). The _TRUE/_FALSE defines for CONFIG_INIT_ON_*_DEFAULT_ON > > were accidentally removed. These need to stay so that the CONFIG controls > > the pessimization of the resulting static branch NOP/JMP locations. > > Changelog doesn't really explain why anyone would want to apply this > patch. This is especially important for -stable patches. > > IOW, what is the user visible effect of the bug? Yeah, that's a good point, and in writing more details I decided this wasn't actually worth a stable patch, and should just get folded into later patches. Thanks for the sanity-check! -- Kees Cook ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-15 17:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20210309214301.678739-1-keescook@chromium.org>
2021-03-09 21:42 ` [PATCH v5 1/7] mm: Restore init_on_* static branch defaults Kees Cook
2021-03-10 23:56 ` Andrew Morton
2021-03-15 17:28 ` Kees Cook
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox