syzbot


KASAN: use-after-free Read in tcindex_dump

Status: fixed on 2020/05/10 10:42
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+653090db2562495901dc@syzkaller.appspotmail.com
Fix commit: b1be2e8cd290 net_sched: hold rtnl lock in tcindex_partial_destroy_work()
First crash: 1507d, last: 1507d
Discussions (4)
Title Replies (including bot) Last reply
[PATCH 5.5 000/170] 5.5.14-rc1 review 180 (180) 2020/04/02 17:40
[PATCH 5.4 000/155] 5.4.29-rc1 review 156 (156) 2020/03/31 08:59
KASAN: use-after-free Read in tcindex_dump 2 (4) 2020/03/16 19:47
[Patch net] net_sched: hold rtnl lock in tcindex_partial_destroy_work() 4 (4) 2020/03/15 03:43
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Read in tcindex_dump 2 536d 596d 0/1 auto-obsoleted due to no activity on 2023/03/03 20:07
linux-4.19 KASAN: use-after-free Read in tcindex_dump 1 1506d 1506d 0/1 auto-closed as invalid on 2020/07/07 00:51
Last patch testing requests (1)
Created Duration User Patch Repo Result
2020/03/11 04:00 18m xiyou.wangcong@gmail.com https://github.com/congwang/linux.git tcindex OK

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in tcindex_dump+0xb6e/0xc20 net/sched/cls_tcindex.c:637
Read of size 8 at addr ffff88807ebd0020 by task syz-executor.3/10006

CPU: 0 PID: 10006 Comm: syz-executor.3 Not tainted 5.6.0-rc4-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_dump+0xb6e/0xc20 net/sched/cls_tcindex.c:637
 tcf_fill_node+0x572/0x930 net/sched/cls_api.c:1814
 tfilter_notify+0x139/0x2a0 net/sched/cls_api.c:1840
 tc_new_tfilter+0xab2/0x20b0 net/sched/cls_api.c:2107
 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:2343
 ___sys_sendmsg+0x100/0x170 net/socket.c:2397
 __sys_sendmsg+0xec/0x1b0 net/socket.c:2430
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45c4a9
Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fb7e5f98c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007fb7e5f996d4 RCX: 000000000045c4a9
RDX: 0000000000000000 RSI: 00000000200001c0 RDI: 0000000000000004
RBP: 000000000076bfc0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 00000000000009fa R14: 00000000004cc777 R15: 000000000076bfcc

Allocated by task 10000:
 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
 __do_kmalloc mm/slab.c:3656 [inline]
 __kmalloc+0x161/0x7a0 mm/slab.c:3665
 kmalloc_array include/linux/slab.h:597 [inline]
 kcalloc include/linux/slab.h:608 [inline]
 tcindex_alloc_perfect_hash+0x5a/0x320 net/sched/cls_tcindex.c:281
 tcindex_set_parms+0x1568/0x1a00 net/sched/cls_tcindex.c:405
 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:2343
 ___sys_sendmsg+0x100/0x170 net/socket.c:2397
 __sys_sendmsg+0xec/0x1b0 net/socket.c:2430
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 262:
 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
 tcindex_partial_destroy_work+0x2e/0x50 net/sched/cls_tcindex.c:264
 process_one_work+0x94b/0x1690 kernel/workqueue.c:2264
 worker_thread+0x96/0xe20 kernel/workqueue.c:2410
 kthread+0x357/0x430 kernel/kthread.c:255
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff88807ebd0000
 which belongs to the cache kmalloc-16k of size 16384
The buggy address is located 32 bytes inside of
 16384-byte region [ffff88807ebd0000, ffff88807ebd4000)
The buggy address belongs to the page:
page:ffffea0001faf400 refcount:1 mapcount:0 mapping:ffff8880aa002380 index:0x0 compound_mapcount: 0
flags: 0xfffe0000010200(slab|head)
raw: 00fffe0000010200 ffffea0001faf208 ffffea0001faf608 ffff8880aa002380
raw: 0000000000000000 ffff88807ebd0000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88807ebcff00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88807ebcff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/03/08 13:29 upstream c20037652700 2e9971bb .config console log report syz ci-upstream-kasan-gce
* Struck through repros no longer work on HEAD.