All of lore.kernel.org
 help / color / mirror / Atom feed
* + mm-kasan-add-a-ksize-test.patch added to -mm tree
@ 2016-04-22 21:34 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2016-04-22 21:34 UTC (permalink / raw)
  To: glider, adech.fo, cl, dvyukov, kcc, ryabinin.a.a, mm-commits


The patch titled
     Subject: mm, kasan: add a ksize() test
has been added to the -mm tree.  Its filename is
     mm-kasan-add-a-ksize-test.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/mm-kasan-add-a-ksize-test.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/mm-kasan-add-a-ksize-test.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Alexander Potapenko <glider@google.com>
Subject: mm, kasan: add a ksize() test

Add a test that makes sure ksize() unpoisons the whole chunk.

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

 lib/test_kasan.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff -puN lib/test_kasan.c~mm-kasan-add-a-ksize-test lib/test_kasan.c
--- a/lib/test_kasan.c~mm-kasan-add-a-ksize-test
+++ a/lib/test_kasan.c
@@ -370,6 +370,25 @@ static noinline void __init kasan_quaran
 }
 #endif
 
+static noinline void __init ksize_unpoisons_memory(void)
+{
+	char *ptr;
+	size_t size = 123, real_size = size;
+
+	pr_info("ksize() unpoisons the whole allocated chunk\n");
+	ptr = kmalloc(size, GFP_KERNEL);
+	if (!ptr) {
+		pr_err("Allocation failed\n");
+		return;
+	}
+	real_size = ksize(ptr);
+	/* This access doesn't trigger an error. */
+	ptr[size] = 'x';
+	/* This one does. */
+	ptr[real_size] = 'y';
+	kfree(ptr);
+}
+
 static int __init kmalloc_tests_init(void)
 {
 	kmalloc_oob_right();
@@ -396,6 +415,7 @@ static int __init kmalloc_tests_init(voi
 #ifdef CONFIG_SLAB
 	kasan_quarantine_cache();
 #endif
+	ksize_unpoisons_memory();
 	return -EAGAIN;
 }
 
_

Patches currently in -mm which might be from glider@google.com are

lib-stackdepotc-allow-the-stack-trace-hash-to-be-zero.patch
mm-kasan-initial-memory-quarantine-implementation.patch
mm-kasan-initial-memory-quarantine-implementation-v8.patch
mm-kasan-dont-call-kasan_krealloc-from-ksize.patch
mm-kasan-add-a-ksize-test.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-04-22 21:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-22 21:34 + mm-kasan-add-a-ksize-test.patch added to -mm tree akpm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.