* + kasan-add-test-for-invalid-size-in-memmove.patch added to -mm tree
@ 2020-03-02 22:37 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2020-03-02 22:37 UTC (permalink / raw)
To: aryabinin, dvyukov, glider, lkp, mm-commits, walter-zh.wu
The patch titled
Subject: kasan: add test for invalid size in memmove
has been added to the -mm tree. Its filename is
kasan-add-test-for-invalid-size-in-memmove.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/kasan-add-test-for-invalid-size-in-memmove.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/kasan-add-test-for-invalid-size-in-memmove.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: Walter Wu <walter-zh.wu@mediatek.com>
Subject: kasan: add test for invalid size in memmove
Test negative size in memmove in order to verify whether it correctly get
KASAN report.
Casting negative numbers to size_t would indeed turn up as a large size_t,
so it will have out-of-bounds bug and be detected by KASAN.
Link: http://lkml.kernel.org/r/20191112065313.7060-1-walter-zh.wu@mediatek.com
Signed-off-by: Walter Wu <walter-zh.wu@mediatek.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: kernel test robot <lkp@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
lib/test_kasan.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
--- a/lib/test_kasan.c~kasan-add-test-for-invalid-size-in-memmove
+++ a/lib/test_kasan.c
@@ -285,6 +285,23 @@ static noinline void __init kmalloc_oob_
kfree(ptr);
}
+static noinline void __init kmalloc_memmove_invalid_size(void)
+{
+ char *ptr;
+ size_t size = 64;
+
+ pr_info("invalid size in memmove\n");
+ ptr = kmalloc(size, GFP_KERNEL);
+ if (!ptr) {
+ pr_err("Allocation failed\n");
+ return;
+ }
+
+ memset((char *)ptr, 0, 64);
+ memmove((char *)ptr, (char *)ptr + 4, -2);
+ kfree(ptr);
+}
+
static noinline void __init kmalloc_uaf(void)
{
char *ptr;
@@ -799,6 +816,7 @@ static int __init kmalloc_tests_init(voi
kmalloc_oob_memset_4();
kmalloc_oob_memset_8();
kmalloc_oob_memset_16();
+ kmalloc_memmove_invalid_size();
kmalloc_uaf();
kmalloc_uaf_memset();
kmalloc_uaf2();
_
Patches currently in -mm which might be from walter-zh.wu@mediatek.com are
kasan-detect-negative-size-in-memory-operation-function.patch
kasan-add-test-for-invalid-size-in-memmove.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-03-02 22:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-02 22:37 + kasan-add-test-for-invalid-size-in-memmove.patch added to -mm tree akpm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).