syzbot


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

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

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: slab-out-of-bounds 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: slab-out-of-bounds Write in tcindex_set_parms C done 2 843d 843d 1/1 fixed on 2020/04/12 11:41
linux-4.14 KASAN: slab-out-of-bounds Write in tcindex_set_parms C done 2 836d 836d 1/1 fixed on 2020/04/17 19:57
Patch testing requests:
Created Duration User Patch Repo Result
2020/03/11 00:34 18m xiyou.wangcong@gmail.com https://github.com/congwang/linux.git tcindex OK

Sample crash report:
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 ffff8880a231e6b8 by task syz-executor747/10502

CPU: 1 PID: 10502 Comm: syz-executor747 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:00007ffead913b38 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00000000004a2650 RCX: 0000000000440e79
RDX: 0000000000000000 RSI: 00000000200001c0 RDI: 0000000000000003
RBP: 00007ffead913b40 R08: 0000000120080522 R09: 0000000120080522
R10: 0000000120080522 R11: 0000000000000246 R12: 00000000004a2650
R13: 0000000000402410 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 10502:
 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]
 tipc_crypto_start+0x77/0x370 net/tipc/crypto.c:1348
 tipc_init_net+0x331/0x5c0 net/tipc/core.c:71
 ops_init+0xaf/0x420 net/core/net_namespace.c:137
 setup_net+0x2d4/0x850 net/core/net_namespace.c:327
 copy_net_ns+0x293/0x590 net/core/net_namespace.c:468
 create_new_namespaces+0x3fb/0xb30 kernel/nsproxy.c:108
 unshare_nsproxy_namespaces+0xbd/0x1f0 kernel/nsproxy.c:229
 ksys_unshare+0x43d/0x8e0 kernel/fork.c:2955
 __do_sys_unshare kernel/fork.c:3023 [inline]
 __se_sys_unshare kernel/fork.c:3021 [inline]
 __x64_sys_unshare+0x2d/0x40 kernel/fork.c:3021
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 2515:
 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 ffff8880a231e600
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 184 bytes inside of
 192-byte region [ffff8880a231e600, ffff8880a231e6c0)
The buggy address belongs to the page:
page:ffffea000288c780 refcount:1 mapcount:0 mapping:ffff8880aa000000 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea0002884d08 ffffea00028895c8 ffff8880aa000000
raw: 0000000000000000 ffff8880a231e000 0000000100000010 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a231e580: 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880a231e600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8880a231e680: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
                                           ^
 ffff8880a231e700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880a231e780: 00 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (10):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-selinux-root 2020/03/22 20:09 upstream b74b991fb8b9 78267cec .config log report syz C
ci-upstream-kasan-gce-root 2020/03/19 08:01 upstream 5076190daded 0a96a13c .config log report syz C
ci-upstream-kasan-gce 2020/03/10 06:28 upstream 30bb5572ce7a 35f53e45 .config log report syz C
ci-upstream-kasan-gce-386 2020/03/10 01:42 upstream 2c523b344dfa 35f53e45 .config log report syz C
ci-upstream-net-this-kasan-gce 2020/03/11 06:57 net ece0d7bd7461 35f53e45 .config log report syz C
ci-upstream-net-this-kasan-gce 2020/03/11 06:16 net ece0d7bd7461 35f53e45 .config log report syz C
ci-upstream-net-kasan-gce 2020/03/10 22:17 net-next 6c9ee3069380 35f53e45 .config log report syz C
ci-upstream-net-kasan-gce 2020/03/08 09:44 net-next 425c075dcbb2 2e9971bb .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/03/30 00:55 linux-next 770fbb32d34e 05736b29 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/03/29 23:35 linux-next 770fbb32d34e 05736b29 .config log report syz C