Thread (47 messages) flat view 47 messages, 5 authors, 2021-01-15

Re: [PATCH 08/11] kasan: adopt kmalloc_uaf2 test to HW_TAGS mode

From: Andrey Konovalov <hidden>
Date: 2021-01-12 22:01:12
Also in: linux-mm, lkml

On Tue, Jan 12, 2021 at 9:26 AM Alexander Potapenko [off-list ref] wrote:
Nit: s/adopt/adapt in the title.

quoted
+again:
        ptr1 = kmalloc(size, GFP_KERNEL);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr1);
@@ -384,6 +386,13 @@ static void kmalloc_uaf2(struct kunit *test)
        ptr2 = kmalloc(size, GFP_KERNEL);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr2);

+       /*
+        * For tag-based KASAN ptr1 and ptr2 tags might happen to be the same.
+        * Allow up to 4 attempts at generating different tags.
+        */
+       if (!IS_ENABLED(CONFIG_KASAN_GENERIC) && ptr1 == ptr2 && counter++ < 4)
+               goto again;
+
Looks like we are leaking memory allocated for ptr2 here?
Will fix in v2, thanks!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help