summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Ryabinin <aryabinin@virtuozzo.com>2016-08-02 14:02:49 -0700
committerPaul Lawrence <paullawrence@google.com>2017-12-14 08:21:25 -0800
commit1f93a556dfaf2e7da5a284d5e58088fcea46ffe9 (patch)
tree71a09f6b46d16548fb45266ea6947fa1c3b784f4
parent30d8b5b40294f132eba25efed83b66f02df6ca3c (diff)
UPSTREAM: mm/kasan: get rid of ->alloc_size in struct kasan_alloc_meta
Size of slab object already stored in cache->object_size. Note, that kmalloc() internally rounds up size of allocation, so object_size may be not equal to alloc_size, but, usually we don't need to know the exact size of allocated object. In case if we need that information, we still can figure it out from the report. The dump of shadow memory allows to identify the end of allocated memory, and thereby the exact allocation size. Link: http://lkml.kernel.org/r/1470062715-14077-4-git-send-email-aryabinin@virtuozzo.com Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: Alexander Potapenko <glider@google.com> Cc: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Bug: 64145065 (cherry-picked from 47b5c2a0f021e90a79845d1a1353780e5edd0bce) Change-Id: I76b555f9a8469f685607ca50f6c51b2e0ad1b4ab Signed-off-by: Paul Lawrence <paullawrence@google.com>
-rw-r--r--mm/kasan/kasan.c1
-rw-r--r--mm/kasan/kasan.h3
-rw-r--r--mm/kasan/report.c8
3 files changed, 4 insertions, 8 deletions
diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index c99ef40ebdfa..388e812ccaca 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -584,7 +584,6 @@ void kasan_kmalloc(struct kmem_cache *cache, const void *object, size_t size,
get_alloc_info(cache, object);
alloc_info->state = KASAN_STATE_ALLOC;
- alloc_info->alloc_size = size;
set_track(&alloc_info->track, flags);
}
}
diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
index bd1ddd8e5474..7da506aa09a1 100644
--- a/mm/kasan/kasan.h
+++ b/mm/kasan/kasan.h
@@ -78,8 +78,7 @@ struct kasan_track {
struct kasan_alloc_meta {
struct kasan_track track;
- u32 state : 2; /* enum kasan_state */
- u32 alloc_size : 30;
+ u32 state;
};
struct qlist_node {
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 1f5168185a9d..d704a5705804 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -137,7 +137,9 @@ static void kasan_object_err(struct kmem_cache *cache, struct page *page,
struct kasan_free_meta *free_info;
dump_stack();
- pr_err("Object at %p, in cache %s\n", object, cache->name);
+ pr_err("Object at %p, in cache %s size: %d\n", object, cache->name,
+ cache->object_size);
+
if (!(cache->flags & SLAB_KASAN))
return;
switch (alloc_info->state) {
@@ -145,15 +147,11 @@ static void kasan_object_err(struct kmem_cache *cache, struct page *page,
pr_err("Object not allocated yet\n");
break;
case KASAN_STATE_ALLOC:
- pr_err("Object allocated with size %u bytes.\n",
- alloc_info->alloc_size);
pr_err("Allocation:\n");
print_track(&alloc_info->track);
break;
case KASAN_STATE_FREE:
case KASAN_STATE_QUARANTINE:
- pr_err("Object freed, allocated with size %u bytes\n",
- alloc_info->alloc_size);
free_info = get_free_info(cache, object);
pr_err("Allocation:\n");
print_track(&alloc_info->track);