[Devel,rh7,13/39] mm, kasan: don't call kasan_krealloc() from ksize().

Submitted by Andrey Ryabinin on Sept. 14, 2017, 4:51 p.m.

Details

Message ID 20170914165156.28876-13-aryabinin@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrey Ryabinin Sept. 14, 2017, 4:51 p.m.
From: Alexander Potapenko <glider@google.com>

Instead of calling kasan_krealloc(), which replaces the memory
allocation stack ID (if stack depot is used), just unpoison the whole
memory chunk.

Signed-off-by: Alexander Potapenko <glider@google.com>
Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andrey Konovalov <adech.fo@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Konstantin Serebryany <kcc@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

https://jira.sw.ru/browse/PSBM-69081
(cherry picked from commit 4ebb31a42ffa03912447fe1aabbdb28242f909ba)
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 mm/slab.c | 2 +-
 mm/slub.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/mm/slab.c b/mm/slab.c
index ba35acc00df1..7f5b2a30c9aa 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -4590,7 +4590,7 @@  size_t ksize(const void *objp)
 	/* We assume that ksize callers could use the whole allocated area,
 	 * so we need to unpoison this area.
 	 */
-	kasan_krealloc(objp, size, GFP_NOWAIT);
+	kasan_unpoison_shadow(objp, size);
 
 	return size;
 }
diff --git a/mm/slub.c b/mm/slub.c
index e32920fa85d1..2a97b19b8855 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3591,8 +3591,9 @@  size_t ksize(const void *object)
 {
 	size_t size = __ksize(object);
 	/* We assume that ksize callers could use whole allocated area,
-	   so we need unpoison this area. */
-	kasan_krealloc(object, size, GFP_NOWAIT);
+	 * so we need to unpoison this area.
+	 */
+	kasan_unpoison_shadow(object, size);
 	return size;
 }
 EXPORT_SYMBOL(ksize);