syzbot


KASAN: use-after-free Read in tcf_action_destroy

Status: fixed on 2020/11/16 12:12
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+2287853d392e4b42374a@syzkaller.appspotmail.com
Fix commit: 0fedc63fadf0 net_sched: commit action insertions together
First crash: 1485d, last: 1466d
Cause bisection: introduced by (bisect log) :
commit 4e8ddd7f1758ca4ddd0c1f7cf3e66fce736241d2
Author: Vlad Buslov <vladbu@mellanox.com>
Date: Thu Jul 5 14:24:30 2018 +0000

  net: sched: don't release reference on action overwrite

Crash: KASAN: use-after-free Read in tcf_action_destroy (log)
Repro: C syz .config
  
Discussions (4)
Title Replies (including bot) Last reply
[PATCH 5.8 000/124] 5.8.15-rc1 review 136 (136) 2020/10/14 18:31
[PATCH 5.4 00/85] 5.4.71-rc1 review 89 (89) 2020/10/14 01:24
[Patch net 0/2] net_sched: fix a UAF in tcf_action_init() 10 (10) 2020/09/28 17:38
KASAN: use-after-free Read in tcf_action_destroy 0 (1) 2020/09/20 15:12
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Read in tcf_action_destroy C error 2 1117d 1476d 0/1 upstream: reported C repro on 2020/09/25 05:47
upstream KASAN: slab-use-after-free Read in tcf_action_destroy net C error 32 517d 592d 22/28 fixed on 2023/06/08 14:41
Last patch testing requests (4)
Created Duration User Patch Repo Result
2020/09/22 16:07 17m xiyou.wangcong@gmail.com https://github.com/congwang/linux.git net OK
2020/09/22 05:54 22m xiyou.wangcong@gmail.com https://github.com/congwang/linux.git net report log
2020/09/21 21:33 10m xiyou.wangcong@gmail.com https://github.com/congwang/linux.git net report log
2020/09/21 19:08 10m xiyou.wangcong@gmail.com https://github.com/congwang/linux.git net report log

Sample crash report:
netlink: 32 bytes leftover after parsing attributes in process `syz-executor795'.
==================================================================
BUG: KASAN: use-after-free in tcf_action_destroy+0x188/0x1b0 net/sched/act_api.c:724
Read of size 8 at addr ffff88809ee75400 by task syz-executor795/6876

CPU: 1 PID: 6876 Comm: syz-executor795 Not tainted 5.9.0-rc8-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+0x198/0x1fd lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xae/0x497 mm/kasan/report.c:383
 __kasan_report mm/kasan/report.c:513 [inline]
 kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
 tcf_action_destroy+0x188/0x1b0 net/sched/act_api.c:724
 tcf_action_init+0x29c/0x3d0 net/sched/act_api.c:1058
 tcf_action_add+0xd9/0x360 net/sched/act_api.c:1451
 tc_ctl_action+0x33a/0x439 net/sched/act_api.c:1504
 rtnetlink_rcv_msg+0x44e/0xad0 net/core/rtnetlink.c:5563
 netlink_rcv_skb+0x15a/0x430 net/netlink/af_netlink.c:2470
 netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1330
 netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1919
 sock_sendmsg_nosec net/socket.c:651 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:671
 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2353
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2407
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2440
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x445d79
Code: e8 bc b7 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 ab 11 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f6a74b28d98 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00000000006dac28 RCX: 0000000000445d79
RDX: 0000000000000000 RSI: 0000000020002980 RDI: 0000000000000003
RBP: 00000000006dac20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dac2c
R13: 0001008400000000 R14: 0000000000000000 R15: 053b003000000098

Allocated by task 6876:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:461
 __do_kmalloc mm/slab.c:3659 [inline]
 __kmalloc+0x1b0/0x360 mm/slab.c:3668
 kmalloc include/linux/slab.h:559 [inline]
 kzalloc include/linux/slab.h:666 [inline]
 tcf_idr_create+0x5b/0x800 net/sched/act_api.c:408
 tcf_connmark_init+0x535/0x960 net/sched/act_connmark.c:126
 tcf_action_init_1+0x6a5/0xac0 net/sched/act_api.c:984
 tcf_action_init+0x260/0x3d0 net/sched/act_api.c:1043
 tcf_action_add+0xd9/0x360 net/sched/act_api.c:1451
 tc_ctl_action+0x33a/0x439 net/sched/act_api.c:1504
 rtnetlink_rcv_msg+0x44e/0xad0 net/core/rtnetlink.c:5563
 netlink_rcv_skb+0x15a/0x430 net/netlink/af_netlink.c:2470
 netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1330
 netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1919
 sock_sendmsg_nosec net/socket.c:651 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:671
 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2353
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2407
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2440
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 6878:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:56
 kasan_set_free_info+0x1b/0x30 mm/kasan/generic.c:355
 __kasan_slab_free+0xd8/0x120 mm/kasan/common.c:422
 __cache_free mm/slab.c:3422 [inline]
 kfree+0x10e/0x2b0 mm/slab.c:3760
 tcf_idr_release_unsafe net/sched/act_api.c:284 [inline]
 tcf_del_walker net/sched/act_api.c:310 [inline]
 tcf_generic_walker+0x959/0xb60 net/sched/act_api.c:339
 tca_action_flush+0x42b/0x920 net/sched/act_api.c:1278
 tca_action_gd+0x8c9/0xe20 net/sched/act_api.c:1385
 tc_ctl_action+0x280/0x439 net/sched/act_api.c:1512
 rtnetlink_rcv_msg+0x44e/0xad0 net/core/rtnetlink.c:5563
 netlink_rcv_skb+0x15a/0x430 net/netlink/af_netlink.c:2470
 netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1330
 netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1919
 sock_sendmsg_nosec net/socket.c:651 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:671
 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2353
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2407
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2440
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff88809ee75400
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 0 bytes inside of
 512-byte region [ffff88809ee75400, ffff88809ee75600)
The buggy address belongs to the page:
page:000000004cb01f57 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x9ee75
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea000287eec8 ffffea0002974108 ffff8880aa040600
raw: 0000000000000000 ffff88809ee75000 0000000100000004 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809ee75300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88809ee75380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88809ee75400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88809ee75480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809ee75500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (8):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/10/05 12:49 upstream 549738f15da0 5ef9c291 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/10/04 05:04 upstream 22fbc037cd32 1a3f9408 .config console log report syz C ci-upstream-kasan-gce-root
2020/09/16 15:50 net-old 2e5117ba9f58 18d7d030 .config console log report syz C ci-upstream-net-this-kasan-gce
2020/09/16 15:23 net-next-old 0f9ad4e75944 18d7d030 .config console log report syz C ci-upstream-net-kasan-gce
2020/09/16 15:33 net-old 2e5117ba9f58 18d7d030 .config console log report info ci-upstream-net-this-kasan-gce
2020/09/20 07:06 net-next-old a5a3303e26cd 53ce8104 .config console log report info ci-upstream-net-kasan-gce
2020/09/19 04:49 net-next-old 1d39cd8cf75f 53ce8104 .config console log report info ci-upstream-net-kasan-gce
2020/09/16 15:07 net-next-old 0f9ad4e75944 18d7d030 .config console log report info ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.