syzbot


KASAN: use-after-free Write in tcindex_set_parms

Status: fixed on 2020/05/10 10:42
Reported-by: syzbot+e5db00b3987d59130da5@syzkaller.appspotmail.com
Fix commit: 0d1c3530e1bd net_sched: keep alloc_hash updated after hash allocation
First crash: 844d, last: 821d

Cause bisection: introduced by (bisect log) :
commit 599be01ee567b61f4471ee8078870847d0a11e8e
Author: Cong Wang <xiyou.wangcong@gmail.com>
Date: Mon Feb 3 05:14:35 2020 +0000

  net_sched: fix an OOB access in cls_tcindex

Crash: KASAN: use-after-free Write in tcindex_set_parms (log)
Repro: C syz .config
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Write in tcindex_set_parms C done 3 840d 844d 1/1 fixed on 2020/04/12 11:41
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

Sample crash report:
IPVS: ftp: loaded support on port[0] = 21
==================================================================
BUG: KASAN: use-after-free in tcindex_set_parms+0x17fd/0x1a00 net/sched/cls_tcindex.c:455
Write of size 16 at addr ffff8880a354dab8 by task syz-executor408/10698

CPU: 0 PID: 10698 Comm: syz-executor408 Not tainted 5.6.0-rc6-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
 tcindex_change+0x203/0x2e0 net/sched/cls_tcindex.c:518
 tc_new_tfilter+0xa59/0x20b0 net/sched/cls_api.c:2103
 rtnetlink_rcv_msg+0x810/0xad0 net/core/rtnetlink.c:5427
 netlink_rcv_skb+0x15a/0x410 net/netlink/af_netlink.c:2478
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x537/0x740 net/netlink/af_netlink.c:1329
 netlink_sendmsg+0x882/0xe10 net/netlink/af_netlink.c:1918
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:672
 ____sys_sendmsg+0x6b9/0x7d0 net/socket.c:2345
 ___sys_sendmsg+0x100/0x170 net/socket.c:2399
 __sys_sendmsg+0xec/0x1b0 net/socket.c:2432
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440e79
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 7b 10 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffecff38fc8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00000000004a2650 RCX: 0000000000440e79
RDX: 0000000000000000 RSI: 00000000200001c0 RDI: 0000000000000003
RBP: 00007ffecff38fd0 R08: 0000000120080522 R09: 0000000120080522
R10: 0000000120080522 R11: 0000000000000246 R12: 00000000004a2650
R13: 0000000000402410 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 1:
 save_stack+0x1b/0x80 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 __kasan_kmalloc mm/kasan/common.c:515 [inline]
 __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:488
 kmem_cache_alloc_trace+0x153/0x7d0 mm/slab.c:3551
 kmalloc include/linux/slab.h:555 [inline]
 kzalloc include/linux/slab.h:669 [inline]
 call_usermodehelper_setup+0x98/0x300 kernel/umh.c:386
 kobject_uevent_env+0xcfb/0x11f0 lib/kobject_uevent.c:613
 tty_register_device_attr+0x475/0x6f0 drivers/tty/tty_io.c:3164
 tty_register_device drivers/tty/tty_io.c:3077 [inline]
 tty_register_driver+0x42d/0x800 drivers/tty/tty_io.c:3348
 legacy_pty_init drivers/tty/pty.c:602 [inline]
 pty_init+0x6cb/0xeb2 drivers/tty/pty.c:964
 do_one_initcall+0x10a/0x7d0 init/main.c:1152
 do_initcall_level init/main.c:1225 [inline]
 do_initcalls init/main.c:1241 [inline]
 do_basic_setup init/main.c:1261 [inline]
 kernel_init_freeable+0x501/0x5ae init/main.c:1445
 kernel_init+0xd/0x1bb init/main.c:1352
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

Freed by task 2259:
 save_stack+0x1b/0x80 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 kasan_set_free_info mm/kasan/common.c:337 [inline]
 __kasan_slab_free+0xf7/0x140 mm/kasan/common.c:476
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x109/0x2b0 mm/slab.c:3757
 call_usermodehelper_freeinfo kernel/umh.c:48 [inline]
 umh_complete kernel/umh.c:62 [inline]
 umh_complete+0x81/0x90 kernel/umh.c:51
 call_usermodehelper_exec_async+0x459/0x710 kernel/umh.c:122
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff8880a354da00
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 184 bytes inside of
 192-byte region [ffff8880a354da00, ffff8880a354dac0)
The buggy address belongs to the page:
page:ffffea00028d5340 refcount:1 mapcount:0 mapping:ffff8880aa000000 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea00028d1088 ffff8880aa001148 ffff8880aa000000
raw: 0000000000000000 ffff8880a354d000 0000000100000010 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a354d980: 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880a354da00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a354da80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                                        ^
 ffff8880a354db00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880a354db80: 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (13):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-selinux-root 2020/03/22 21:29 upstream b74b991fb8b9 78267cec .config log report syz C
ci-upstream-kasan-gce-selinux-root 2020/03/22 19:30 upstream b74b991fb8b9 78267cec .config log report syz C
ci-upstream-kasan-gce-root 2020/03/19 04:31 upstream 5076190daded 0a96a13c .config log report syz C
ci-upstream-kasan-gce 2020/03/10 07:48 upstream 30bb5572ce7a 35f53e45 .config log report syz C
ci-upstream-kasan-gce 2020/03/10 05:48 upstream 30bb5572ce7a 35f53e45 .config log report syz C
ci-upstream-net-this-kasan-gce 2020/03/11 19:01 net 2165fdf4bc2d e7caca8e .config log report syz C
ci-upstream-net-kasan-gce 2020/03/11 10:15 net-next 1e09e5818b3a 35f53e45 .config log report syz C
ci-upstream-net-kasan-gce 2020/03/10 21:36 net-next 6c9ee3069380 35f53e45 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/03/30 16:35 linux-next 770fbb32d34e c8d1cc20 .config log report syz C
ci-upstream-kasan-gce-root 2020/03/19 03:46 upstream 5076190daded 0a96a13c .config log report syz
ci-upstream-kasan-gce 2020/03/10 16:33 upstream 30bb5572ce7a 35f53e45 .config log report syz
ci-upstream-net-kasan-gce 2020/03/10 21:03 net-next 6c9ee3069380 35f53e45 .config log report syz
ci-upstream-kasan-gce-386 2020/03/08 09:08 upstream c20037652700 2e9971bb .config log report