From: Andrey Ryabinin <aryabinin@virtuozzo.com>
To: akpm@linux-foundation.org
Cc: glider@google.com, dvyukov@google.com, iamjoonsoo.kim@lge.com,
kasan-dev@googlegroups.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Andrey Ryabinin <aryabinin@virtuozzo.com>
Subject: [PATCH] mm-kasan-switch-slub-to-stackdepot-enable-memory-quarantine-for-slub-fix
Date: Fri, 15 Jul 2016 19:50:23 +0300 [thread overview]
Message-ID: <1468601423-28676-1-git-send-email-aryabinin@virtuozzo.com> (raw)
- 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@virtuozzo.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
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2016-07-15 16:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-15 16:50 Andrey Ryabinin [this message]
2016-07-15 17:17 ` Alexander Potapenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1468601423-28676-1-git-send-email-aryabinin@virtuozzo.com \
--to=aryabinin@virtuozzo.com \
--cc=akpm@linux-foundation.org \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox