2020-12-04 19:00:07

by Jeffrin Thalakkottoor

[permalink] [raw]
Subject: BUG: KASAN lib/test_kasan.c

hello,

detected KASAN BUG

[ related information ]

-------------------x-------------------x------------------------>
[ 43.616259] BUG: KASAN: vmalloc-out-of-bounds in
vmalloc_oob+0x146/0x2c0

(gdb) l *vmalloc_oob+0x146/0x2c0
0xffffffff81b8b0b0 is in vmalloc_oob (lib/test_kasan.c:764).
759 kfree_sensitive(ptr);
760 KUNIT_EXPECT_KASAN_FAIL(test, kfree_sensitive(ptr));
761 }
762
763 static void vmalloc_oob(struct kunit *test)
764 {
765 void *area;
766
767 if (!IS_ENABLED(CONFIG_KASAN_VMALLOC)) {
768 kunit_info(test, "CONFIG_KASAN_VMALLOC is not
enabled.");
(gdb) l *vmalloc_oob+0x146
0xffffffff81b8b1f6 is in vmalloc_oob (lib/test_kasan.c:779).
774 * The MMU will catch that and crash us.
775 */
776 area = vmalloc(3000);
777 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, area);
778
779 KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char
*)area)[3100]);
780 vfree(area);
781 }
782
783 static struct kunit_case kasan_kunit_test_cases[] = {
----------------x-----------------------------x-------------------->

Reported by: Jeffrin Jose T <[email protected]>

--
software engineer
rajagiri school of engineering and technology - autonomous



2020-12-04 20:32:28

by Marco Elver

[permalink] [raw]
Subject: Re: BUG: KASAN lib/test_kasan.c

On Fri, 4 Dec 2020 at 19:56, Jeffrin Jose T <[email protected]> wrote:
> hello,
>
> detected KASAN BUG
>
> [ related information ]
>
> -------------------x-------------------x------------------------>
> [ 43.616259] BUG: KASAN: vmalloc-out-of-bounds in
> vmalloc_oob+0x146/0x2c0
>
> (gdb) l *vmalloc_oob+0x146/0x2c0
> 0xffffffff81b8b0b0 is in vmalloc_oob (lib/test_kasan.c:764).

This is the KASAN test. It's a feature, not a bug. ;-)

> 759 kfree_sensitive(ptr);
> 760 KUNIT_EXPECT_KASAN_FAIL(test, kfree_sensitive(ptr));
> 761 }
> 762
> 763 static void vmalloc_oob(struct kunit *test)
> 764 {
> 765 void *area;
> 766
> 767 if (!IS_ENABLED(CONFIG_KASAN_VMALLOC)) {
> 768 kunit_info(test, "CONFIG_KASAN_VMALLOC is not
> enabled.");
> (gdb) l *vmalloc_oob+0x146
> 0xffffffff81b8b1f6 is in vmalloc_oob (lib/test_kasan.c:779).
> 774 * The MMU will catch that and crash us.
> 775 */
> 776 area = vmalloc(3000);
> 777 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, area);
> 778
> 779 KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char
> *)area)[3100]);
> 780 vfree(area);
> 781 }
> 782
> 783 static struct kunit_case kasan_kunit_test_cases[] = {
> ----------------x-----------------------------x-------------------->
>
> Reported by: Jeffrin Jose T <[email protected]>

Which CI system is reporting these?

If you look, this is the KASAN test, and the report is very much
intended since it's testing KASAN. Please blacklist the KASAN test
(and any other tests testing debugging tools).

Thanks,
-- Marco

2020-12-04 20:55:42

by Jeffrin Thalakkottoor

[permalink] [raw]
Subject: Re: BUG: KASAN lib/test_kasan.c

On Fri, 2020-12-04 at 21:29 +0100, Marco Elver wrote:
> On Fri, 4 Dec 2020 at 19:56, Jeffrin Jose T
> <[email protected]> wrote:
> > hello,
> >
> >  detected   KASAN   BUG
> >
> > [ related information ]
> >
> > -------------------x-------------------x------------------------>
> > [   43.616259] BUG: KASAN: vmalloc-out-of-bounds in
> > vmalloc_oob+0x146/0x2c0
> >
> > (gdb) l *vmalloc_oob+0x146/0x2c0
> > 0xffffffff81b8b0b0 is in vmalloc_oob (lib/test_kasan.c:764).
>
> This is the KASAN test. It's a feature, not a bug. ;-)
>
> > 759             kfree_sensitive(ptr);
> > 760             KUNIT_EXPECT_KASAN_FAIL(test,
> > kfree_sensitive(ptr));
> > 761     }
> > 762
> > 763     static void vmalloc_oob(struct kunit *test)
> > 764     {
> > 765             void *area;
> > 766
> > 767             if (!IS_ENABLED(CONFIG_KASAN_VMALLOC)) {
> > 768                     kunit_info(test, "CONFIG_KASAN_VMALLOC is
> > not
> > enabled.");
> > (gdb) l *vmalloc_oob+0x146
> > 0xffffffff81b8b1f6 is in vmalloc_oob (lib/test_kasan.c:779).
> > 774              * The MMU will catch that and crash us.
> > 775              */
> > 776             area = vmalloc(3000);
> > 777             KUNIT_ASSERT_NOT_ERR_OR_NULL(test, area);
> > 778
> > 779             KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char
> > *)area)[3100]);
> > 780             vfree(area);
> > 781     }
> > 782
> > 783     static struct kunit_case kasan_kunit_test_cases[] = {
> > ----------------x-----------------------------x--------------------
> > >
> >
> > Reported by: Jeffrin Jose T <[email protected]>
>
> Which CI system is reporting these?
>
> If you look, this is the KASAN test, and the report is very much
> intended since it's testing KASAN. Please blacklist the KASAN test
> (and any other tests testing debugging tools).
>
> Thanks,
> -- Marco

gdb session was started by me. (gdb ./vmlinux)

portion from dmesg output is as follows
--------------------x------------------------x-------------------------
-->
[ 43.616259] BUG: KASAN: vmalloc-out-of-bounds in
vmalloc_oob+0x146/0x2c0
[ 43.630470] Read of size 1 at addr ffffc9000006ec1c by task
kunit_try_catch/193

[ 43.659055] CPU: 2 PID: 193 Comm: kunit_try_catch Tainted: G B
5.10.0-rc6+ #10
[ 43.659070] Hardware name: ASUSTeK COMPUTER INC. VivoBook 15_ASUS
Laptop X507UAR/X507UAR, BIOS X507UAR.203 05/31/2018
[ 43.659080] Call Trace:
[ 43.659105] dump_stack+0x119/0x179
[ 43.659131] print_address_description.constprop.0+0x1c/0x210
[ 43.659163] ? vmalloc_oob+0x146/0x2c0
[ 43.659185] kasan_report.cold+0x1f/0x37
[ 43.659210] ? vmalloc_oob+0x146/0x2c0
[ 43.659234] vmalloc_oob+0x146/0x2c0
[ 43.659259] ? kasan_global_oob+0x280/0x280
[ 43.659287] ? kunit_fail_assert_format+0xa0/0xa0
[ 43.659313] ? lock_release+0xb2/0x730
[ 43.659334] ? __kthread_parkme+0xa1/0x120
[ 43.659356] ? lock_acquired+0xb4/0x5b0
[ 43.659379] ? lock_downgrade+0x3d0/0x3d0
[ 43.659403] ? lock_contended+0x6e0/0x6e0
[ 43.659423] ? do_raw_spin_lock+0x1b0/0x1b0
[ 43.659447] ? io_schedule_timeout+0xb0/0xb0
[ 43.659467] ? static_obj+0x31/0x80
[ 43.659492] ? lockdep_hardirqs_on_prepare+0xe/0x240
[ 43.659517] ? memcg_accounted_kmem_cache+0x1b0/0x1b0
[ 43.659542] kunit_try_run_case+0xa6/0x150
[ 43.659567] ? kunit_catch_run_case+0x170/0x170
[ 43.659591] ? kunit_try_catch_throw+0x40/0x40
[ 43.659617] kunit_generic_run_threadfn_adapter+0x2e/0x50
[ 43.659637] kthread+0x232/0x260
[ 43.659659] ? __kthread_bind_mask+0x90/0x90
[ 43.659684] ret_from_fork+0x22/0x30


[ 43.686511] Memory state around the buggy address:
[ 43.700445] ffffc9000006eb00: 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00
[ 43.714559] ffffc9000006eb80: 00 00 00 00 00 00 00 f8 f8 f8 f8 f8
f8 f8 f8 f8
[ 43.728725] >ffffc9000006ec00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
f8 f8 f8 f8
[ 43.742808] ^
[ 43.757156] ffffc9000006ec80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
f8 f8 f8 f8
[ 43.771845] ffffc9000006ed00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
f8 f8 f8 f8
[ 43.785957]
==================================================================

-------------------x-----------------------------x---------------------
---------->


--
software engineer
rajagiri school of engineering and technology - autonomous