• Andrey Konovalov's avatar
    kasan, slub: fix HW_TAGS zeroing with slub_debug · fdb54d96
    Andrey Konovalov authored
    Commit 946fa0db ("mm/slub: extend redzone check to extra allocated
    kmalloc space than requested") added precise kmalloc redzone poisoning to
    the slub_debug functionality.
    
    However, this commit didn't account for HW_TAGS KASAN fully initializing
    the object via its built-in memory initialization feature.  Even though
    HW_TAGS KASAN memory initialization contains special memory initialization
    handling for when slub_debug is enabled, it does not account for in-object
    slub_debug redzones.  As a result, HW_TAGS KASAN can overwrite these
    redzones and cause false-positive slub_debug reports.
    
    To fix the issue, avoid HW_TAGS KASAN memory initialization when
    slub_debug is enabled altogether.  Implement this by moving the
    __slub_debug_enabled check to slab_post_alloc_hook.  Common slab code
    seems like a more appropriate place for a slub_debug check anyway.
    
    Link: https://lkml.kernel.org/r/678ac92ab790dba9198f9ca14f405651b97c8502.1688561016.git.andreyknvl@google.com
    Fixes: 946fa0db ("mm/slub: extend redzone check to extra allocated kmalloc space than requested")
    Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
    Reported-by: default avatarWill Deacon <will@kernel.org>
    Acked-by: default avatarMarco Elver <elver@google.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Alexander Potapenko <glider@google.com>
    Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Christoph Lameter <cl@linux.com>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Dmitry Vyukov <dvyukov@google.com>
    Cc: Feng Tang <feng.tang@intel.com>
    Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
    Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
    Cc: kasan-dev@googlegroups.com
    Cc: Pekka Enberg <penberg@kernel.org>
    Cc: Peter Collingbourne <pcc@google.com>
    Cc: Roman Gushchin <roman.gushchin@linux.dev>
    Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    fdb54d96
kasan.h 18.9 KB