kasan-revert-eviction-of-stack-traces-in-generic-mode.patch removed from -mm tree
The quilt patch titled
Subject: kasan: revert eviction of stack traces in generic mode
has been removed from the -mm tree. Its filename was
kasan-revert-eviction-of-stack-traces-in-generic-mode.patch
This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Marco Elver <[email protected]>
Subject: kasan: revert eviction of stack traces in generic mode
Date: Mon, 29 Jan 2024 11:07:02 +0100
This partially reverts commits cc478e0b6bdf, 63b85ac56a64, 08d7c94d9635, a414d4286f34, and 773688a6cb24 to make use of variable-sized stack depot records, since eviction of stack entries from stack depot forces fixed- sized stack records. Care was taken to retain the code cleanups by the above commits.
Eviction was added to generic KASAN as a response to alleviating the additional memory usage from fixed-sized stack records, but this still uses more memory than previously.
With the re-introduction of variable-sized records for stack depot, we can just switch back to non-evictable stack records again, and return back to the previous performance and memory usage baseline.
Before (observed after a KASAN kernel boot):
pools: 597
refcounted_allocations: 17547
refcounted_frees: 6477
refcounted_in_use: 11070
freelist_size: 3497
persistent_count: 12163
persistent_bytes: 1717008
After:
pools: 319
refcounted_allocations: 0
refcounted_frees: 0
refcounted_in_use: 0
freelist_size: 0
persistent_count: 29397
persistent_bytes: 5183536
As can be seen from the counters, with a generic KASAN config, refcounted allocations and evictions are no longer used. Due to using variable-sized records, I observe a reduction of 278 stack depot pools (saving 4448 KiB) with my test setup.
---
mm/kasan/common.c | 8 +--- mm/kasan/generic.c | 68 ++++------------------------------------ mm/kasan/kasan.h | 10 ----- mm/kasan/quarantine.c | 5 ++ 4 files changed, 14 insertions(+), 77 deletions(-)
mm/kasan/common.c renamed from mm/kasan/common.c~kasan-revert-eviction-of-stack-traces-in-generic-mode +3 -5
@@ -65,8 +65,7 @@ void kasan_save_track(struct kasan_track {depot_stack_handle_t stack; - stack =kasan_save_stack (flags, -STACK_DEPOT_FLAG_CAN_ALLOC |STACK_DEPOT_FLAG_GET ); + stack =kasan_save_stack (flags,STACK_DEPOT_FLAG_CAN_ALLOC );kasan_set_track (track, stack); }
@@ -266,10 +265,9 @@ bool __kasan_slab_free(struct kmem_cachereturn true;/* -* If the object is not put into quarantine, it will likely be quickly -* reallocated. Thus, release its metadata now. +* Note: Keep per-object metadata to allow KASAN print stack traces for +* use-after-free-before-realloc bugs. */ -kasan_release_object_meta (cache, object);/* Let slab put the object onto the freelist. */ return false;
mm/kasan/generic.c renamed from mm/kasan/generic.c~kasan-revert-eviction-of-stack-traces-in-generic-mode +7 -61
123 lines not on this page · raw message
mm/kasan/kasan.h renamed from mm/kasan/kasan.h~kasan-revert-eviction-of-stack-traces-in-generic-mode +0 -10
@@ -6,7 +6,6 @@#include <linux/kasan.h> #include <linux/kasan-tags.h> #include <linux/kfence.h> -#include <linux/spinlock.h> #include <linux/stackdepot.h> #if defined(CONFIG_KASAN_SW_TAGS ) || defined(CONFIG_KASAN_HW_TAGS )
@@ -265,13 +264,6 @@ struct kasan_global {struct kasan_alloc_meta {struct kasan_track alloc_track;/* Free track is stored in kasan_free_meta. */ -/* -* aux_lock protects aux_stack from accesses from concurrent -* kasan_record_aux_stack calls. It is a raw spinlock to avoid sleeping -* on RT kernels, as kasan_record_aux_stack_noalloc can be called from -* non-sleepable contexts. -*/ -raw_spinlock_t aux_lock;depot_stack_handle_t aux_stack[2 ]; };
@@ -398,10 +390,8 @@ struct kasan_alloc_meta *kasan_get_allocstruct kasan_free_meta *kasan_get_free_meta (struct kmem_cache *cache,const void *object);void kasan_init_object_meta (struct kmem_cache *cache,const void *object); -void kasan_release_object_meta (struct kmem_cache *cache,const void *object);#else static inline void kasan_init_object_meta (struct kmem_cache *cache,const void *object) { } -static inline void kasan_release_object_meta (struct kmem_cache *cache,const void *object) { }#endif depot_stack_handle_t kasan_save_stack (gfp_t flags,depot_flags_t depot_flags);
mm/kasan/quarantine.c renamed from mm/kasan/quarantine.c~kasan-revert-eviction-of-stack-traces-in-generic-mode +4 -1
@@ -145,7 +145,10 @@ static void qlink_free(struct qlist_nodevoid *object =qlink_to_object (qlink, cache);struct kasan_free_meta *free_meta =kasan_get_free_meta (cache, object); -kasan_release_object_meta (cache, object); +/* +* Note: Keep per-object metadata to allow KASAN print stack traces for +* use-after-free-before-realloc bugs. +*/ /* * If init_on_free is enabled and KASAN's free metadata is stored in
_
Patches currently in -mm which might be from [email protected] are