summaryrefslogtreecommitdiffstats
path: root/include/linux/kasan.h
diff options
context:
space:
mode:
authorAndrey Ryabinin <a.ryabinin@samsung.com>2015-04-15 19:15:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-15 19:35:20 -0400
commit923936157b158f36bd6a3d86496dce82b1a957de (patch)
tree4a78fc384c220efad52d250b49795b535fbc2db0 /include/linux/kasan.h
parentbda6d33042a486c8f7b15bf15a80fd07d4eab204 (diff)
mm/mempool.c: kasan: poison mempool elements
Mempools keep allocated objects in reserved for situations when ordinary allocation may not be possible to satisfy. These objects shouldn't be accessed before they leave the pool. This patch poison elements when get into the pool and unpoison when they leave it. This will let KASan to detect use-after-free of mempool's elements. Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com> Tested-by: David Rientjes <rientjes@google.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Dmitry Chernenkov <drcheren@gmail.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Alexander Potapenko <glider@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/kasan.h')
-rw-r--r--include/linux/kasan.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/kasan.h b/include/linux/kasan.h
index 5bb074431eb0..5486d777b706 100644
--- a/include/linux/kasan.h
+++ b/include/linux/kasan.h
@@ -44,6 +44,7 @@ void kasan_poison_object_data(struct kmem_cache *cache, void *object);
44 44
45void kasan_kmalloc_large(const void *ptr, size_t size); 45void kasan_kmalloc_large(const void *ptr, size_t size);
46void kasan_kfree_large(const void *ptr); 46void kasan_kfree_large(const void *ptr);
47void kasan_kfree(void *ptr);
47void kasan_kmalloc(struct kmem_cache *s, const void *object, size_t size); 48void kasan_kmalloc(struct kmem_cache *s, const void *object, size_t size);
48void kasan_krealloc(const void *object, size_t new_size); 49void kasan_krealloc(const void *object, size_t new_size);
49 50
@@ -71,6 +72,7 @@ static inline void kasan_poison_object_data(struct kmem_cache *cache,
71 72
72static inline void kasan_kmalloc_large(void *ptr, size_t size) {} 73static inline void kasan_kmalloc_large(void *ptr, size_t size) {}
73static inline void kasan_kfree_large(const void *ptr) {} 74static inline void kasan_kfree_large(const void *ptr) {}
75static inline void kasan_kfree(void *ptr) {}
74static inline void kasan_kmalloc(struct kmem_cache *s, const void *object, 76static inline void kasan_kmalloc(struct kmem_cache *s, const void *object,
75 size_t size) {} 77 size_t size) {}
76static inline void kasan_krealloc(const void *object, size_t new_size) {} 78static inline void kasan_krealloc(const void *object, size_t new_size) {}