• Kees Cook's avatar
    mm/slab: Plumb kmem_buckets into __do_kmalloc_node() · 67f2df3b
    Kees Cook authored
    Introduce CONFIG_SLAB_BUCKETS which provides the infrastructure to
    support separated kmalloc buckets (in the following kmem_buckets_create()
    patches and future codetag-based separation). Since this will provide
    a mitigation for a very common case of exploits, it is recommended to
    enable this feature for general purpose distros. By default, the new
    Kconfig will be enabled if CONFIG_SLAB_FREELIST_HARDENED is enabled (and
    it is added to the hardening.config Kconfig fragment).
    
    To be able to choose which buckets to allocate from, make the buckets
    available to the internal kmalloc interfaces by adding them as the
    second argument, rather than depending on the buckets being chosen from
    the fixed set of global buckets. Where the bucket is not available,
    pass NULL, which means "use the default system kmalloc bucket set"
    (the prior existing behavior), as implemented in kmalloc_slab().
    
    To avoid adding the extra argument when !CONFIG_SLAB_BUCKETS, only the
    top-level macros and static inlines use the buckets argument (where
    they are stripped out and compiled out respectively). The actual extern
    functions can then be built without the argument, and the internals
    fall back to the global kmalloc buckets unconditionally.
    Co-developed-by: default avatarVlastimil Babka <vbabka@suse.cz>
    Signed-off-by: default avatarKees Cook <kees@kernel.org>
    Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
    67f2df3b
hardening.config 3.12 KB