BACKPORT: kasan: only define metadata structs for Generic mode

(Backport: no conflcits, neighboring lines changed.)

Hide the definitions of kasan_alloc_meta and kasan_free_meta under an
ifdef CONFIG_KASAN_GENERIC check, as these structures are now only used
when the Generic mode is enabled.

Link: https://lkml.kernel.org/r/8d2aabff8c227c444a3f62edf87d5630beb77640.1662411799.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Reviewed-by: Marco Elver <elver@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Evgenii Stepanov <eugenis@google.com>
Cc: Peter Collingbourne <pcc@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Bug: 254721825
(cherry picked from commit be95e13fcc)
Change-Id: I7a76d388e12a7a177df1710dbbeae32a3ec545bb
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
This commit is contained in:
Andrey Konovalov
2022-09-05 23:05:32 +02:00
parent 9c83df526f
commit 9a1008367a

View File

@@ -199,14 +199,12 @@ struct kasan_track {
depot_stack_handle_t stack;
};
#ifdef CONFIG_KASAN_GENERIC
struct kasan_alloc_meta {
struct kasan_track alloc_track;
/* Generic mode stores free track in kasan_free_meta. */
#ifdef CONFIG_KASAN_GENERIC
/* Free track is stored in kasan_free_meta. */
depot_stack_handle_t aux_stack[2];
#else
struct kasan_track free_track;
#endif
};
struct qlist_node {
@@ -225,12 +223,12 @@ struct qlist_node {
* After that, slab allocator stores the freelist pointer in the object.
*/
struct kasan_free_meta {
#ifdef CONFIG_KASAN_GENERIC
struct qlist_node quarantine_link;
struct kasan_track free_track;
#endif
};
#endif /* CONFIG_KASAN_GENERIC */
#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
static inline const void *kasan_shadow_to_mem(const void *shadow_addr)