syzbot


KASAN: use-after-free Read in tcf_block_find

Status: fixed on 2018/11/12 21:25
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+37b8770e6d5a8220a039@syzkaller.appspotmail.com
Fix commit: 460b360104d5 net_sched: fix a crash in tc_new_tfilter()
First crash: 2036d, last: 2029d
Discussions (3)
Title Replies (including bot) Last reply
[PATCH 4.19 00/74] 4.19.221-rc1 review 87 (87) 2021/12/15 17:54
[Patch net-next] net_sched: fix an extack message in tcf_block_find() 11 (11) 2018/09/30 14:12
KASAN: use-after-free Read in tcf_block_find 11 (12) 2018/09/27 18:04

Sample crash report:
8021q: adding VLAN 0 to HW filter on device team0
==================================================================
BUG: KASAN: use-after-free in tcf_block_find+0x9d1/0xb90 net/sched/cls_api.c:646
Read of size 4 at addr ffff8801ba84cdb8 by task syz-executor970/5595

CPU: 1 PID: 5595 Comm: syz-executor970 Not tainted 4.19.0-rc5+ #237
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+0x1c4/0x2b4 lib/dump_stack.c:113
 print_address_description.cold.8+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
 tcf_block_find+0x9d1/0xb90 net/sched/cls_api.c:646
 tc_new_tfilter+0x497/0x1d20 net/sched/cls_api.c:1331
 rtnetlink_rcv_msg+0x46a/0xc20 net/core/rtnetlink.c:4730
 netlink_rcv_skb+0x172/0x440 net/netlink/af_netlink.c:2447
 rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:4748
 netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
 netlink_unicast+0x5a5/0x760 net/netlink/af_netlink.c:1336
 netlink_sendmsg+0xa18/0xfc0 net/netlink/af_netlink.c:1901
 sock_sendmsg_nosec net/socket.c:621 [inline]
 sock_sendmsg+0xd5/0x120 net/socket.c:631
 ___sys_sendmsg+0x7fd/0x930 net/socket.c:2116
 __sys_sendmsg+0x11d/0x280 net/socket.c:2154
 __do_sys_sendmsg net/socket.c:2163 [inline]
 __se_sys_sendmsg net/socket.c:2161 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2161
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x441a19
Code: e8 0c ac 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 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 fb 04 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffdcea67198 EFLAGS: 00000213 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000441a19
RDX: 0000000000000000 RSI: 0000000020005000 RDI: 0000000000000003
RBP: 000000000000de28 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000023f7880 R11: 0000000000000213 R12: 0000000000000000
R13: 0000000000402430 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 5414:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 __do_kmalloc_node mm/slab.c:3682 [inline]
 __kmalloc_node+0x47/0x70 mm/slab.c:3689
 kmalloc_node include/linux/slab.h:555 [inline]
 kzalloc_node include/linux/slab.h:718 [inline]
 qdisc_alloc+0x10f/0xb50 net/sched/sch_generic.c:820
 qdisc_create_dflt+0x7a/0x1e0 net/sched/sch_generic.c:894
 attach_one_default_qdisc net/sched/sch_generic.c:1041 [inline]
 netdev_for_each_tx_queue include/linux/netdevice.h:2114 [inline]
 attach_default_qdiscs net/sched/sch_generic.c:1060 [inline]
 dev_activate+0x82f/0xcb0 net/sched/sch_generic.c:1103
 __dev_open+0x2cb/0x410 net/core/dev.c:1400
 __dev_change_flags+0x730/0x9b0 net/core/dev.c:7448
 dev_change_flags+0x89/0x150 net/core/dev.c:7517
 do_setlink+0xb5f/0x3f20 net/core/rtnetlink.c:2441
 rtnl_newlink+0x136f/0x1d40 net/core/rtnetlink.c:3054
 rtnetlink_rcv_msg+0x46a/0xc20 net/core/rtnetlink.c:4730
 netlink_rcv_skb+0x172/0x440 net/netlink/af_netlink.c:2447
 rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:4748
 netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
 netlink_unicast+0x5a5/0x760 net/netlink/af_netlink.c:1336
 netlink_sendmsg+0xa18/0xfc0 net/netlink/af_netlink.c:1901
 sock_sendmsg_nosec net/socket.c:621 [inline]
 sock_sendmsg+0xd5/0x120 net/socket.c:631
 ___sys_sendmsg+0x7fd/0x930 net/socket.c:2116
 __sys_sendmsg+0x11d/0x280 net/socket.c:2154
 __do_sys_sendmsg net/socket.c:2163 [inline]
 __se_sys_sendmsg net/socket.c:2161 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2161
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 0:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xcf/0x230 mm/slab.c:3813
 qdisc_free+0x89/0x100 net/sched/sch_generic.c:941
 qdisc_free_cb+0x19/0x20 net/sched/sch_generic.c:948
 __rcu_reclaim kernel/rcu/rcu.h:236 [inline]
 rcu_do_batch kernel/rcu/tree.c:2576 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:2880 [inline]
 __rcu_process_callbacks kernel/rcu/tree.c:2847 [inline]
 rcu_process_callbacks+0xf23/0x2670 kernel/rcu/tree.c:2864
 __do_softirq+0x30b/0xad8 kernel/softirq.c:292

The buggy address belongs to the object at ffff8801ba84cd80
 which belongs to the cache kmalloc-1024 of size 1024
The buggy address is located 56 bytes inside of
 1024-byte region [ffff8801ba84cd80, ffff8801ba84d180)
The buggy address belongs to the page:
page:ffffea0006ea1300 count:1 mapcount:0 mapping:ffff8801da800ac0 index:0x0 compound_mapcount: 0
flags: 0x2fffc0000008100(slab|head)
raw: 02fffc0000008100 ffffea00075ee908 ffffea00075df688 ffff8801da800ac0
raw: 0000000000000000 ffff8801ba84c000 0000000100000007 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801ba84cc80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801ba84cd00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8801ba84cd80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                        ^
 ffff8801ba84ce00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801ba84ce80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (27):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/09/30 06:17 net-next-old d4017665854b 41e4b329 .config console log report syz C ci-upstream-net-kasan-gce
2018/09/28 01:09 net-next-old 1042caa79e93 0c2fa87b .config console log report syz C ci-upstream-net-kasan-gce
2018/09/26 14:35 net-next-old 4b1bd6976945 455b6354 .config console log report syz C ci-upstream-net-kasan-gce
2018/09/26 11:08 net-next-old 4b1bd6976945 455b6354 .config console log report syz C ci-upstream-net-kasan-gce
2018/10/01 07:25 linux-next 4794a36bf08d 41e4b329 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/10/01 07:15 linux-next 4794a36bf08d 41e4b329 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/10/01 06:41 linux-next 4794a36bf08d 41e4b329 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/09/30 15:10 linux-next 4794a36bf08d 41e4b329 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/09/30 05:09 linux-next 4794a36bf08d 41e4b329 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/09/28 00:46 linux-next 9e27e2c2d003 0c2fa87b .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/09/30 04:09 net-next-old d4017665854b 41e4b329 .config console log report syz ci-upstream-net-kasan-gce
2018/10/01 02:28 linux-next 4794a36bf08d 41e4b329 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2018/09/30 09:22 linux-next 4794a36bf08d 41e4b329 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2018/10/02 01:18 net-next-old 3bd09b05b068 e06f7713 .config console log report ci-upstream-net-kasan-gce
2018/09/30 00:10 net-next-old d4017665854b 41e4b329 .config console log report ci-upstream-net-kasan-gce
2018/09/28 15:13 net-next-old 1042caa79e93 137d7c66 .config console log report ci-upstream-net-kasan-gce
2018/09/27 21:06 net-next-old 1042caa79e93 0c2fa87b .config console log report ci-upstream-net-kasan-gce
2018/09/26 09:20 net-next-old 4b1bd6976945 455b6354 .config console log report ci-upstream-net-kasan-gce
2018/09/26 08:47 net-next-old 4b1bd6976945 455b6354 .config console log report ci-upstream-net-kasan-gce
2018/09/26 08:07 net-next-old 4b1bd6976945 b7e11289 .config console log report ci-upstream-net-kasan-gce
2018/10/02 15:15 linux-next 62f3d25900c9 a316a2af .config console log report ci-upstream-linux-next-kasan-gce-root
2018/10/01 08:46 linux-next 4794a36bf08d 48a50c6b .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/30 00:11 linux-next 4794a36bf08d 41e4b329 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/28 15:45 linux-next 4794a36bf08d 137d7c66 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/27 19:10 linux-next 9e27e2c2d003 0c2fa87b .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/27 19:07 linux-next 9e27e2c2d003 0c2fa87b .config console log report ci-upstream-linux-next-kasan-gce-root
2018/09/27 18:48 linux-next 9e27e2c2d003 0c2fa87b .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.