syzbot


KASAN: use-after-free Write in tcindex_set_parms

Status: fixed on 2020/04/12 11:41
Reported-by: syzbot+c968a5d63b1dad9f8838@syzkaller.appspotmail.com
Fix commit: 557d015ffb27 net_sched: keep alloc_hash updated after hash allocation
First crash: 844d, last: 840d

Fix bisection: fixed by (bisect log) :
commit 557d015ffb27b672e24e6ad141fd887783871dc2
Author: Cong Wang <xiyou.wangcong@gmail.com>
Date: Thu Mar 12 05:42:28 2020 +0000

  net_sched: keep alloc_hash updated after hash allocation

similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Write in tcindex_set_parms C done 3 833d 833d 1/1 fixed on 2020/04/18 14:50
upstream KASAN: use-after-free Write in tcindex_set_parms C done 13 821d 841d 17/22 fixed on 2020/05/10 10:42

Sample crash report:
audit: type=1400 audit(1583984978.463:38): avc:  denied  { write } for  pid=8174 comm="syz-executor469" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_generic_socket permissive=1
==================================================================
audit: type=1400 audit(1583984978.463:39): avc:  denied  { read } for  pid=8174 comm="syz-executor469" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_generic_socket permissive=1
BUG: KASAN: use-after-free in tcindex_set_parms+0x17d0/0x19d0 net/sched/cls_tcindex.c:455
Write of size 16 at addr ffff8880a7b8cb30 by task syz-executor469/8174

CPU: 0 PID: 8174 Comm: syz-executor469 Not tainted 4.19.109-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.cold+0x7c/0x212 mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report mm/kasan/report.c:412 [inline]
 kasan_report.cold+0x88/0x2b9 mm/kasan/report.c:396
 tcindex_set_parms+0x17d0/0x19d0 net/sched/cls_tcindex.c:455
 tcindex_change+0x200/0x2d3 net/sched/cls_tcindex.c:517
 tc_new_tfilter+0xa6b/0x1450 net/sched/cls_api.c:1320
 rtnetlink_rcv_msg+0x453/0xaf0 net/core/rtnetlink.c:4777
 netlink_rcv_skb+0x160/0x410 net/netlink/af_netlink.c:2455
 netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
 netlink_unicast+0x4d7/0x6a0 net/netlink/af_netlink.c:1344
 netlink_sendmsg+0x80b/0xcd0 net/netlink/af_netlink.c:1909
 sock_sendmsg_nosec net/socket.c:622 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:632
 ___sys_sendmsg+0x803/0x920 net/socket.c:2115
 __sys_sendmsg+0xec/0x1b0 net/socket.c:2153
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x442799
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 5b 10 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffee099d978 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007ffee099d9b0 RCX: 0000000000442799
RDX: 0000000000000000 RSI: 00000000200001c0 RDI: 0000000000000003
RBP: 0000000000000003 R08: 0000000000020003 R09: 0000000000020003
R10: 0000000000020003 R11: 0000000000000246 R12: 0000000000000003
R13: 0000000000000004 R14: 00007ffee099da60 R15: 0000000000000000

Allocated by task 1:
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc mm/kasan/kasan.c:553 [inline]
 kasan_kmalloc+0xbf/0xe0 mm/kasan/kasan.c:531
 kmem_cache_alloc_trace+0x14d/0x7a0 mm/slab.c:3625
 kmalloc include/linux/slab.h:515 [inline]
 kzalloc include/linux/slab.h:709 [inline]
 call_usermodehelper_setup+0x77/0x2f0 kernel/umh.c:381
 kobject_uevent_env+0xc92/0x1160 lib/kobject_uevent.c:611
 tty_register_device_attr+0x46e/0x6f0 drivers/tty/tty_io.c:3020
 tty_register_device drivers/tty/tty_io.c:2933 [inline]
 tty_register_driver+0x42d/0x800 drivers/tty/tty_io.c:3204
 vty_init+0x3ac/0x3e7 drivers/tty/vt/vt.c:3437
 tty_init+0x187/0x18b drivers/tty/tty_io.c:3363
 chr_dev_init+0x141/0x151 drivers/char/mem.c:965
 do_one_initcall+0xf1/0x734 init/main.c:883
 do_initcall_level init/main.c:951 [inline]
 do_initcalls init/main.c:959 [inline]
 do_basic_setup init/main.c:977 [inline]
 kernel_init_freeable+0x4c9/0x5bb init/main.c:1144
 kernel_init+0xd/0x1c0 init/main.c:1061
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

Freed by task 1310:
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0xf7/0x140 mm/kasan/kasan.c:521
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xce/0x220 mm/slab.c:3822
 call_usermodehelper_freeinfo kernel/umh.c:45 [inline]
 umh_complete kernel/umh.c:59 [inline]
 umh_complete+0x81/0x90 kernel/umh.c:48
 call_usermodehelper_exec_async+0x542/0x630 kernel/umh.c:117
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

The buggy address belongs to the object at ffff8880a7b8cb00
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 48 bytes inside of
 192-byte region [ffff8880a7b8cb00, ffff8880a7b8cbc0)
The buggy address belongs to the page:
page:ffffea00029ee300 count:1 mapcount:0 mapping:ffff88812c3dc040 index:0x0
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffffea000296e148 ffffea0002975448 ffff88812c3dc040
raw: 0000000000000000 ffff8880a7b8c000 0000000100000010 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a7b8ca00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880a7b8ca80: 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880a7b8cb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                     ^
 ffff8880a7b8cb80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8880a7b8cc00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (3):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-linux-4-19 2020/03/12 03:52 linux-4.19.y 569209711609 d850e9d0 .config log report syz C
ci2-linux-4-19 2020/03/08 09:29 linux-4.19.y 7472c4028e23 2e9971bb .config log report syz C
ci2-linux-4-19 2020/03/11 07:35 linux-4.19.y 7472c4028e23 35f53e45 .config log report syz