Re: KASAN: slab-out-of-bounds Write in tcindex_set_parms

From: Cong Wang
Date: Tue Mar 10 2020 - 14:31:24 EST


On Sun, Mar 8, 2020 at 3:44 PM syzbot
<syzbot+c72da7b9ed57cde6fca2@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit: 425c075d Merge branch 'tun-debug'
> git tree: net-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=134d2ae3e00000
> kernel config: https://syzkaller.appspot.com/x/.config?x=598678fc6e800071
> dashboard link: https://syzkaller.appspot.com/bug?extid=c72da7b9ed57cde6fca2
> compiler: gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=122ed70de00000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=116689fde00000
>
> The bug was bisected to:
>
> commit 599be01ee567b61f4471ee8078870847d0a11e8e
> Author: Cong Wang <xiyou.wangcong@xxxxxxxxx>
> Date: Mon Feb 3 05:14:35 2020 +0000
>
> net_sched: fix an OOB access in cls_tcindex
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=150a7d53e00000
> final crash: https://syzkaller.appspot.com/x/report.txt?x=170a7d53e00000
> console output: https://syzkaller.appspot.com/x/log.txt?x=130a7d53e00000
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+c72da7b9ed57cde6fca2@xxxxxxxxxxxxxxxxxxxxxxxxx
> Fixes: 599be01ee567 ("net_sched: fix an OOB access in cls_tcindex")
>
> IPVS: ftp: loaded support on port[0] = 21
> ==================================================================
> BUG: KASAN: slab-out-of-bounds in tcindex_set_parms+0x17fd/0x1a00 net/sched/cls_tcindex.c:455
> Write of size 16 at addr ffff8880a219e6b8 by task syz-executor508/9705
>
> CPU: 1 PID: 9705 Comm: syz-executor508 Not tainted 5.6.0-rc3-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> Call Trace:
> __dump_stack lib/dump_stack.c:77 [inline]
> dump_stack+0x188/0x20d lib/dump_stack.c:118
> print_address_description.constprop.0.cold+0xd3/0x315 mm/kasan/report.c:374
> __kasan_report.cold+0x1a/0x32 mm/kasan/report.c:506
> kasan_report+0xe/0x20 mm/kasan/common.c:641
> tcindex_set_parms+0x17fd/0x1a00 net/sched/cls_tcindex.c:455


I think we probably don't check the boundary of 'handle' properly.

397 if (cp->perfect || valid_perfect_hash(cp))
398 if (handle >= cp->alloc_hash)
399 goto errout_alloc;

I will think more about it.

Thanks.