syzbot


KASAN: slab-out-of-bounds Read in tcf_exts_destroy

Status: fixed on 2020/02/18 14:31
Reported-by: syzbot+35d4dea36c387813ed31@syzkaller.appspotmail.com
Fix commit: 599be01ee567 net_sched: fix an OOB access in cls_tcindex
First crash: 1004d, last: 987d

Cause bisection: introduced by (bisect log) :
commit 6e237d099fac1f73a7b6d7287bb9191f29585a4e
Author: David Ahern <dsahern@gmail.com>
Date: Thu Dec 7 04:09:12 2017 +0000

  netlink: Relax attr validation for fixed length types

Crash: WARNING: kmalloc bug in tcindex_alloc_perfect_hash (log)
Repro: C syz .config

Fix bisection: failed (bisect log)
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: slab-out-of-bounds Read in tcf_exts_destroy C done 1 873d 989d 1/1 fixed on 2020/03/11 23:02
linux-4.14 KASAN: slab-out-of-bounds Read in tcf_exts_destroy C done 1 872d 985d 1/1 fixed on 2020/03/12 12:23
Patch testing requests:
Created Duration User Patch Repo Result
2020/02/02 03:15 18m xiyou.wangcong@gmail.com https://github.com/congwang/linux.git syzbot OK
2020/02/01 20:24 4m xiyou.wangcong@gmail.com https://github.com/congwang/linux.git syzbot error
2020/02/01 02:56 4m xiyou.wangcong@gmail.com https://github.com/congwang/linux.git syzbot error
2020/01/31 20:59 5m xiyou.wangcong@gmail.com https://github.com/congwang/linux.git syzbot error

Sample crash report:
netlink: 'syz-executor864': attribute type 2 has an invalid length.
netlink: 'syz-executor864': attribute type 2 has an invalid length.
==================================================================
BUG: KASAN: slab-out-of-bounds in tcf_exts_destroy+0xb3/0xd0 net/sched/cls_api.c:2897
Read of size 8 at addr ffff8880a2d3ee90 by task syz-executor864/9612

CPU: 1 PID: 9612 Comm: syz-executor864 Not tainted 5.4.0-rc3+ #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+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
 __kasan_report.cold+0x1b/0x41 mm/kasan/report.c:506
 kasan_report+0x12/0x20 mm/kasan/common.c:634
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
 tcf_exts_destroy+0xb3/0xd0 net/sched/cls_api.c:2897
 tcindex_free_perfect_hash.isra.0+0xb3/0x150 net/sched/cls_tcindex.c:273
 tcindex_set_parms+0x1107/0x1e50 net/sched/cls_tcindex.c:484
 tcindex_change+0x230/0x320 net/sched/cls_tcindex.c:519
 tc_new_tfilter+0xa4b/0x1c70 net/sched/cls_api.c:2019
 rtnetlink_rcv_msg+0x838/0xb00 net/core/rtnetlink.c:5214
 netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477
 rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:5241
 netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
 netlink_unicast+0x531/0x710 net/netlink/af_netlink.c:1328
 netlink_sendmsg+0x8a5/0xd60 net/netlink/af_netlink.c:1917
 sock_sendmsg_nosec net/socket.c:637 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:657
 ___sys_sendmsg+0x3e2/0x920 net/socket.c:2311
 __sys_sendmmsg+0x1bf/0x4d0 net/socket.c:2413
 __do_sys_sendmmsg net/socket.c:2442 [inline]
 __se_sys_sendmmsg net/socket.c:2439 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2439
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x443299
Code: e8 9c 07 03 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 3b 0a fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffd04c95d08 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000443299
RDX: 0000000000000332 RSI: 0000000020000140 RDI: 0000000000000008
RBP: 000000000000000c R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0030766461746162
R13: 00000000004041f0 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 9612:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 __kasan_kmalloc mm/kasan/common.c:510 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:483
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:524
 __do_kmalloc mm/slab.c:3655 [inline]
 __kmalloc+0x163/0x770 mm/slab.c:3664
 kmalloc_array include/linux/slab.h:618 [inline]
 kcalloc include/linux/slab.h:629 [inline]
 tcindex_alloc_perfect_hash+0x5a/0x320 net/sched/cls_tcindex.c:281
 tcindex_set_parms+0x454/0x1e50 net/sched/cls_tcindex.c:339
 tcindex_change+0x230/0x320 net/sched/cls_tcindex.c:519
 tc_new_tfilter+0xa4b/0x1c70 net/sched/cls_api.c:2019
 rtnetlink_rcv_msg+0x838/0xb00 net/core/rtnetlink.c:5214
 netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477
 rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:5241
 netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
 netlink_unicast+0x531/0x710 net/netlink/af_netlink.c:1328
 netlink_sendmsg+0x8a5/0xd60 net/netlink/af_netlink.c:1917
 sock_sendmsg_nosec net/socket.c:637 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:657
 ___sys_sendmsg+0x3e2/0x920 net/socket.c:2311
 __sys_sendmmsg+0x1bf/0x4d0 net/socket.c:2413
 __do_sys_sendmmsg net/socket.c:2442 [inline]
 __se_sys_sendmmsg net/socket.c:2439 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2439
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 23:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 kasan_set_free_info mm/kasan/common.c:332 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:471
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:480
 __cache_free mm/slab.c:3425 [inline]
 kfree+0x10a/0x2c0 mm/slab.c:3756
 sbitmap_free include/linux/sbitmap.h:164 [inline]
 blk_mq_hw_sysfs_release+0xc5/0x170 block/blk-mq-sysfs.c:44
 kobject_cleanup lib/kobject.c:693 [inline]
 kobject_release lib/kobject.c:722 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put.cold+0x289/0x2e6 lib/kobject.c:739
 blk_mq_release+0x258/0x410 block/blk-mq.c:2686
 __blk_release_queue+0x20c/0x380 block/blk-sysfs.c:902
 process_one_work+0x9af/0x1740 kernel/workqueue.c:2269
 worker_thread+0x98/0xe40 kernel/workqueue.c:2415
 kthread+0x361/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 ffff8880a2d3ee00
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 144 bytes inside of
 192-byte region [ffff8880a2d3ee00, ffff8880a2d3eec0)
The buggy address belongs to the page:
page:ffffea00028b4f80 refcount:1 mapcount:0 mapping:ffff8880aa400000 index:0x0
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea00028b4808 ffffea000287c3c8 ffff8880aa400000
raw: 0000000000000000 ffff8880a2d3e000 0000000100000010 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a2d3ed80: 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880a2d3ee00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8880a2d3ee80: 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                         ^
 ffff8880a2d3ef00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880a2d3ef80: 00 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (8):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-selinux-root 2019/10/18 22:59 upstream 0e2adab6cf28 8c88c9c1 .config log report syz C
ci-upstream-kasan-gce-root 2019/10/13 21:43 upstream da94001239cc 2f661ec4 .config log report syz C
ci-upstream-kasan-gce-smack-root 2019/10/13 19:40 upstream da94001239cc 2f661ec4 .config log report syz C
ci-upstream-kasan-gce 2019/10/06 05:48 upstream b145b0eb2031 f3f7d9c8 .config log report syz C
ci-upstream-kasan-gce-386 2019/10/06 20:16 upstream 43b815c6a8e7 f3f7d9c8 .config log report syz C
ci-upstream-net-this-kasan-gce 2019/10/01 22:35 net 569aad4fcd82 b7a87a83 .config log report syz C
ci-upstream-net-kasan-gce 2019/10/02 15:14 net-next c01ebd6c4698 2e29b534 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2019/10/17 13:28 linux-next 3ef845da3c3b 8c88c9c1 .config log report syz C