kasan-add-ability-to-detect-double-kmem_cache_destroy.patch removed from -mm tree
The patch titled
Subject: kasan: add ability to detect double-kmem_cache_destroy()
has been removed from the -mm tree. Its filename was
kasan-add-ability-to-detect-double-kmem_cache_destroy.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Marco Elver <[email protected]>
Subject: kasan: add ability to detect double-kmem_cache_destroy()
Because mm/slab_common.c is not instrumented with software KASAN modes, it is not possible to detect use-after-free of the kmem_cache passed into kmem_cache_destroy(). In particular, because of the s->refcount-- and subsequent early return if non-zero, KASAN would never be able to see the double-free via kmem_cache_free(kmem_cache, s). To be able to detect a double-kmem_cache_destroy(), check accessibility of the kmem_cache, and in case of failure return early.
While KASAN_HW_TAGS is able to detect such bugs, by checking accessibility and returning early we fail more gracefully and also avoid corrupting reused objects (where tags mismatch).
A recent case of a double-kmem_cache_destroy() was detected by KFENCE:
https://lkml.kernel.org/r/[email protected], which was not detectable by software KASAN modes.
---
mm/slab_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/slab_common.c renamed from mm/slab_common.c~kasan-add-ability-to-detect-double-kmem_cache_destroy +1 -1
@@ -489,7 +489,7 @@ void slab_kmem_cache_release(struct kmemvoid kmem_cache_destroy (struct kmem_cache *s) { -if (unlikely (!s)) +if (unlikely (!s) || !kasan_check_byte (s))return ;cpus_read_lock ();
_
Patches currently in -mm which might be from [email protected] are
lib-stackdepot-always-do-filter_irq_stacks-in-stack_depot_save.patch