[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1468601423-28676-1-git-send-email-aryabinin@virtuozzo.com>
Date: Fri, 15 Jul 2016 19:50:23 +0300
From: Andrey Ryabinin <aryabinin@...tuozzo.com>
To: <akpm@...ux-foundation.org>
CC: <glider@...gle.com>, <dvyukov@...gle.com>,
<iamjoonsoo.kim@....com>, <kasan-dev@...glegroups.com>,
<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
Andrey Ryabinin <aryabinin@...tuozzo.com>
Subject: [PATCH] mm-kasan-switch-slub-to-stackdepot-enable-memory-quarantine-for-slub-fix
- Remove CONFIG_SLAB ifdefs. The code works just fine with both allocators.
- Reset metada offsets if metadata doesn't fit. Otherwise kasan_metadata_size()
will give us the wrong results.
Signed-off-by: Andrey Ryabinin <aryabinin@...tuozzo.com>
---
mm/kasan/kasan.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index d92a7a2..b6f99e8 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -372,9 +372,7 @@ void kasan_cache_create(struct kmem_cache *cache, size_t *size,
unsigned long *flags)
{
int redzone_adjust;
-#ifdef CONFIG_SLAB
int orig_size = *size;
-#endif
/* Add alloc meta. */
cache->kasan_info.alloc_meta_offset = *size;
@@ -392,25 +390,20 @@ void kasan_cache_create(struct kmem_cache *cache, size_t *size,
if (redzone_adjust > 0)
*size += redzone_adjust;
-#ifdef CONFIG_SLAB
- *size = min(KMALLOC_MAX_SIZE,
- max(*size,
- cache->object_size +
- optimal_redzone(cache->object_size)));
+ *size = min(KMALLOC_MAX_SIZE, max(*size, cache->object_size +
+ optimal_redzone(cache->object_size)));
+
/*
* If the metadata doesn't fit, don't enable KASAN at all.
*/
if (*size <= cache->kasan_info.alloc_meta_offset ||
*size <= cache->kasan_info.free_meta_offset) {
+ cache->kasan_info.alloc_meta_offset = 0;
+ cache->kasan_info.free_meta_offset = 0;
*size = orig_size;
return;
}
-#else
- *size = max(*size,
- cache->object_size +
- optimal_redzone(cache->object_size));
-#endif
*flags |= SLAB_KASAN;
}
--
2.7.3
Powered by blists - more mailing lists