linux-stable/mm/kasan
Zqiang 802282dc66 kasan: prevent cpu_quarantine corruption when CPU offline and cache shrink occur at same time
commit 31fa985b41 upstream.

kasan_quarantine_remove_cache() is called in kmem_cache_shrink()/
destroy().  The kasan_quarantine_remove_cache() call is protected by
cpuslock in kmem_cache_destroy() to ensure serialization with
kasan_cpu_offline().

However the kasan_quarantine_remove_cache() call is not protected by
cpuslock in kmem_cache_shrink().  When a CPU is going offline and cache
shrink occurs at same time, the cpu_quarantine may be corrupted by
interrupt (per_cpu_remove_cache operation).

So add a cpu_quarantine offline flags check in per_cpu_remove_cache().

[akpm@linux-foundation.org: add comment, per Zqiang]

Link: https://lkml.kernel.org/r/20220414025925.2423818-1-qiang1.zhang@intel.com
Signed-off-by: Zqiang <qiang1.zhang@intel.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-05-09 09:16:29 +02:00
..
common.c lib/stackdepot: always do filter_irq_stacks() in stack_depot_save() 2022-01-22 08:33:38 +02:00
generic.c mm/kasan: Convert to struct folio and struct slab 2022-01-06 12:26:14 +01:00
hw_tags.c kasan: add kasan mode messages when kasan init 2021-11-11 09:34:35 -08:00
init.c kasan: use MAX_PTRS_PER_* for early shadow tables 2021-06-29 10:53:53 -07:00
kasan.h mm/kasan: Convert to struct folio and struct slab 2022-01-06 12:26:14 +01:00
Makefile kasan: integrate the common part of two KASAN tag-based modes 2021-06-29 10:53:53 -07:00
quarantine.c kasan: prevent cpu_quarantine corruption when CPU offline and cache shrink occur at same time 2022-05-09 09:16:29 +02:00
report.c mm/kasan: Convert to struct folio and struct slab 2022-01-06 12:26:14 +01:00
report_generic.c mm/kasan: switch from strlcpy to strscpy 2021-04-30 11:20:41 -07:00
report_hw_tags.c kasan: integrate the common part of two KASAN tag-based modes 2021-06-29 10:53:53 -07:00
report_sw_tags.c kasan: integrate the common part of two KASAN tag-based modes 2021-06-29 10:53:53 -07:00
report_tags.c mm/kasan: Convert to struct folio and struct slab 2022-01-06 12:26:14 +01:00
shadow.c mm: defer kmemleak object creation of module_alloc() 2022-01-15 16:30:25 +02:00
sw_tags.c kasan: add kasan mode messages when kasan init 2021-11-11 09:34:35 -08:00
tags.c kasan: integrate the common part of two KASAN tag-based modes 2021-06-29 10:53:53 -07:00