+ lib-test_kasan-add-test-for-double-kzfree-detection.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: lib/test_kasan: Add test for double-kzfree detection
has been added to the -mm tree.  Its filename is
     lib-test_kasan-add-test-for-double-kzfree-detection.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/lib-test_kasan-add-test-for-double-kzfree-detection.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/lib-test_kasan-add-test-for-double-kzfree-detection.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/process/submit-checklist.rst when testing your code ***

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

------------------------------------------------------
From: Marco Elver <elver@xxxxxxxxxx>
Subject: lib/test_kasan: Add test for double-kzfree detection

Adds a simple test that checks if double-kzfree is being detected
correctly.

Link: http://lkml.kernel.org/r/20190626142014.141844-4-elver@xxxxxxxxxx
Signed-off-by: Marco Elver <elver@xxxxxxxxxx>
Cc: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx>
Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx>
Cc: Alexander Potapenko <glider@xxxxxxxxxx>
Cc: Andrey Konovalov <andreyknvl@xxxxxxxxxx>
Cc: Christoph Lameter <cl@xxxxxxxxx>
Cc: Pekka Enberg <penberg@xxxxxxxxxx>
Cc: David Rientjes <rientjes@xxxxxxxxxx>
Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
Cc: Mark Rutland <mark.rutland@xxxxxxx>
Cc: Kees Cook <keescook@xxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

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

--- a/lib/test_kasan.c~lib-test_kasan-add-test-for-double-kzfree-detection
+++ a/lib/test_kasan.c
@@ -693,6 +693,22 @@ static noinline void __init kasan_bitops
 	kfree(bits);
 }
 
+static noinline void __init kmalloc_double_kzfree(void)
+{
+	char *ptr;
+	size_t size = 16;
+
+	pr_info("double-free (kzfree)\n");
+	ptr = kmalloc(size, GFP_KERNEL);
+	if (!ptr) {
+		pr_err("Allocation failed\n");
+		return;
+	}
+
+	kzfree(ptr);
+	kzfree(ptr);
+}
+
 static int __init kmalloc_tests_init(void)
 {
 	/*
@@ -735,6 +751,7 @@ static int __init kmalloc_tests_init(voi
 	kasan_memcmp();
 	kasan_strings();
 	kasan_bitops();
+	kmalloc_double_kzfree();
 
 	kasan_restore_multi_shot(multishot);
 
_

Patches currently in -mm which might be from elver@xxxxxxxxxx are

mm-kasan-print-frame-description-for-stack-bugs.patch
lib-test_kasan-add-bitops-tests.patch
x86-use-static_cpu_has-in-uaccess-region-to-avoid-instrumentation.patch
asm-generic-x86-add-bitops-instrumentation-for-kasan.patch
mm-kasan-introduce-__kasan_check_readwrite.patch
mm-kasan-change-kasan_check_readwrite-to-return-boolean.patch
lib-test_kasan-add-test-for-double-kzfree-detection.patch
mm-slab-refactor-common-ksize-kasan-logic-into-slab_commonc.patch
mm-kasan-add-object-validation-in-ksize.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux