Re: [PATCH v6 2/6] init_on_alloc: Optimize static branches
From: Kees Cook <hidden>
Date: 2021-03-15 22:16:34
Also in:
linux-hardening, linux-mm, lkml
From: Kees Cook <hidden>
Date: 2021-03-15 22:16:34
Also in:
linux-hardening, linux-mm, lkml
On Mon, Mar 15, 2021 at 11:02:25AM -0700, Kees Cook wrote:
diff --git a/mm/slab.h b/mm/slab.h index 076582f58f68..b0977d525c06 100644 --- a/mm/slab.h +++ b/mm/slab.h@@ -601,7 +601,8 @@ static inline void cache_random_seq_destroy(struct kmem_cache *cachep) { } static inline bool slab_want_init_on_alloc(gfp_t flags, struct kmem_cache *c) { - if (static_branch_unlikely(&init_on_alloc)) { + if (static_branch_maybe(CONFIG_INIT_ON_FREE_DEFAULT_ON,
Gah, this should be CONFIG_INIT_ON_ALLOC_DEFAULT_ON. I'll see if there are any more comments before sending a v7... -Kees
+ &init_on_alloc)) { if (c->ctor) return false; if (c->flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON))@@ -613,7 +614,8 @@ static inline bool slab_want_init_on_alloc(gfp_t flags, struct kmem_cache *c) static inline bool slab_want_init_on_free(struct kmem_cache *c) { - if (static_branch_unlikely(&init_on_free)) + if (static_branch_maybe(CONFIG_INIT_ON_FREE_DEFAULT_ON, + &init_on_free)) return !(c->ctor || (c->flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON))); return false;-- 2.25.1
-- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel