mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-24 02:24:28 +08:00
lib/stackdepot: add printk_deferred_enter/exit guards
Patch series "lib/stackdepot, kasan: fixes for stack eviction series", v3. A few fixes for the stack depot eviction series ("stackdepot: allow evicting stack traces"). This patch (of 5): Stack depot functions can be called from various contexts that do allocations, including with console locks taken. At the same time, stack depot functions might print WARNING's or refcount-related failures. This can cause a deadlock on console locks. Add printk_deferred_enter/exit guards to stack depot to avoid this. Link: https://lkml.kernel.org/r/cover.1703020707.git.andreyknvl@google.com Link: https://lkml.kernel.org/r/82092f9040d075a161d1264377d51e0bac847e8a.1703020707.git.andreyknvl@google.com Fixes:108be8def4
("lib/stackdepot: allow users to evict stack traces") Fixes:cd11016e5f
("mm, kasan: stackdepot implementation. Enable stackdepot for SLAB") Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> Closes: https://lore.kernel.org/all/000000000000f56750060b9ad216@google.com/ Reviewed-by: Marco Elver <elver@google.com> Cc: Alexander Potapenko <glider@google.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Evgenii Stepanov <eugenis@google.com> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
8ab3b09755
commit
a914d8d6cf
@ -506,12 +506,14 @@ depot_stack_handle_t stack_depot_save_flags(unsigned long *entries,
|
||||
bucket = &stack_table[hash & stack_hash_mask];
|
||||
|
||||
read_lock_irqsave(&pool_rwlock, flags);
|
||||
printk_deferred_enter();
|
||||
|
||||
/* Fast path: look the stack trace up without full locking. */
|
||||
found = find_stack(bucket, entries, nr_entries, hash);
|
||||
if (found) {
|
||||
if (depot_flags & STACK_DEPOT_FLAG_GET)
|
||||
refcount_inc(&found->count);
|
||||
printk_deferred_exit();
|
||||
read_unlock_irqrestore(&pool_rwlock, flags);
|
||||
goto exit;
|
||||
}
|
||||
@ -520,6 +522,7 @@ depot_stack_handle_t stack_depot_save_flags(unsigned long *entries,
|
||||
if (new_pool_required)
|
||||
need_alloc = true;
|
||||
|
||||
printk_deferred_exit();
|
||||
read_unlock_irqrestore(&pool_rwlock, flags);
|
||||
|
||||
/*
|
||||
@ -541,6 +544,7 @@ depot_stack_handle_t stack_depot_save_flags(unsigned long *entries,
|
||||
}
|
||||
|
||||
write_lock_irqsave(&pool_rwlock, flags);
|
||||
printk_deferred_enter();
|
||||
|
||||
found = find_stack(bucket, entries, nr_entries, hash);
|
||||
if (!found) {
|
||||
@ -562,6 +566,7 @@ depot_stack_handle_t stack_depot_save_flags(unsigned long *entries,
|
||||
depot_keep_new_pool(&prealloc);
|
||||
}
|
||||
|
||||
printk_deferred_exit();
|
||||
write_unlock_irqrestore(&pool_rwlock, flags);
|
||||
exit:
|
||||
if (prealloc) {
|
||||
@ -600,9 +605,11 @@ unsigned int stack_depot_fetch(depot_stack_handle_t handle,
|
||||
return 0;
|
||||
|
||||
read_lock_irqsave(&pool_rwlock, flags);
|
||||
printk_deferred_enter();
|
||||
|
||||
stack = depot_fetch_stack(handle);
|
||||
|
||||
printk_deferred_exit();
|
||||
read_unlock_irqrestore(&pool_rwlock, flags);
|
||||
|
||||
*entries = stack->entries;
|
||||
@ -619,6 +626,7 @@ void stack_depot_put(depot_stack_handle_t handle)
|
||||
return;
|
||||
|
||||
write_lock_irqsave(&pool_rwlock, flags);
|
||||
printk_deferred_enter();
|
||||
|
||||
stack = depot_fetch_stack(handle);
|
||||
if (WARN_ON(!stack))
|
||||
@ -633,6 +641,7 @@ void stack_depot_put(depot_stack_handle_t handle)
|
||||
}
|
||||
|
||||
out:
|
||||
printk_deferred_exit();
|
||||
write_unlock_irqrestore(&pool_rwlock, flags);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(stack_depot_put);
|
||||
|
Loading…
Reference in New Issue
Block a user