linux-stable/mm/kasan
Benjamin Gray 2597c9947b kasan: guard release_free_meta() shadow access with kasan_arch_is_ready()
release_free_meta() accesses the shadow directly through the path

  kasan_slab_free
    __kasan_slab_free
      kasan_release_object_meta
        release_free_meta
          kasan_mem_to_shadow

There are no kasan_arch_is_ready() guards here, allowing an oops when the
shadow is not initialized.  The oops can be seen on a Power8 KVM guest.

This patch adds the guard to release_free_meta(), as it's the first level
that specifically requires the shadow.

It is safe to put the guard at the start of this function, before the
stack put: only kasan_save_free_info() can initialize the saved stack,
which itself is guarded with kasan_arch_is_ready() by its caller
poison_slab_object().  If the arch becomes ready before
release_free_meta() then we will not observe KASAN_SLAB_FREE_META in the
object's shadow, so we will not put an uninitialized stack either.

Link: https://lkml.kernel.org/r/20240213033958.139383-1-bgray@linux.ibm.com
Fixes: 63b85ac56a ("kasan: stop leaking stack trace handles")
Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-02-20 14:20:50 -08:00
..
Makefile kasan: test: fix test for new meminstrinsic instrumentation 2023-03-02 21:54:22 -08:00
common.c Many singleton patches against the MM code. The patch series which 2024-01-09 11:18:47 -08:00
generic.c kasan: guard release_free_meta() shadow access with kasan_arch_is_ready() 2024-02-20 14:20:50 -08:00
hw_tags.c kasan: check kasan_vmalloc_enabled in vmalloc tests 2023-12-29 11:58:45 -08:00
init.c kasan: Add (pmd|pud)_init for LoongArch zero_(pud|p4d)_populate process 2023-09-06 22:54:16 +08:00
kasan.h Many singleton patches against the MM code. The patch series which 2024-01-09 11:18:47 -08:00
kasan_test.c kasan: speed up match_all_mem_tag test for SW_TAGS 2023-12-29 11:58:46 -08:00
kasan_test_module.c kasan: unify printk prefixes 2023-10-18 14:34:15 -07:00
quarantine.c Many singleton patches against the MM code. The patch series which 2024-01-09 11:18:47 -08:00
report.c Many singleton patches against the MM code. The patch series which 2024-01-09 11:18:47 -08:00
report_generic.c kasan: stop leaking stack trace handles 2024-01-05 10:17:45 -08:00
report_hw_tags.c kasan: use internal prototypes matching gcc-13 builtins 2023-06-09 16:25:19 -07:00
report_sw_tags.c kasan: use internal prototypes matching gcc-13 builtins 2023-06-09 16:25:19 -07:00
report_tags.c kasan: simplify kasan_complete_mode_report_info for tag-based modes 2023-12-29 11:58:47 -08:00
shadow.c kasan: export kasan_poison as GPL 2023-12-29 11:58:45 -08:00
sw_tags.c kasan: use internal prototypes matching gcc-13 builtins 2023-06-09 16:25:19 -07:00
tags.c kasan: simplify saving extra info into tracks 2023-12-29 11:58:46 -08:00