KASAN: use-after-free Write in tcindex_change

Status: fixed on 2020/11/16 12:12
Subsystems: net
[Documentation on labels]
Fix commit: 0d1c3530e1bd net_sched: keep alloc_hash updated after hash allocation
First crash: 1555d, last: 1555d
Cause bisection: introduced by (bisect log) :
commit 599be01ee567b61f4471ee8078870847d0a11e8e
Author: Cong Wang <>
Date: Mon Feb 3 05:14:35 2020 +0000

  net_sched: fix an OOB access in cls_tcindex

Crash: KASAN: use-after-free Write in tcindex_set_parms (log)
Repro: C syz .config
Fix bisection: fixed by (bisect log) :
commit 0d1c3530e1bd38382edef72591b78e877e0edcd3
Author: Cong Wang <>
Date: Thu Mar 12 05:42:28 2020 +0000

  net_sched: keep alloc_hash updated after hash allocation

Discussions (1)
Title Replies (including bot) Last reply
KASAN: use-after-free Write in tcindex_change 1 (4) 2020/11/11 13:11
Last patch testing requests (3)
Created Duration User Patch Repo Result
2020/09/02 16:19 16m 83b43045308ea0600099830292955f18818f8d5e OK
2020/09/02 16:08 9m 599be01ee567b61f4471ee8078870847d0a11e8e report log
2020/09/02 01:35 15m master OK

Sample crash report:
IPVS: ftp: loaded support on port[0] = 21
BUG: KASAN: use-after-free in tcindex_set_parms net/sched/cls_tcindex.c:455 [inline]
BUG: KASAN: use-after-free in tcindex_change+0x1c61/0x27b0 net/sched/cls_tcindex.c:518
Write of size 16 at addr ffff8880a7596330 by task syz-executor325/8447

CPU: 1 PID: 8447 Comm: syz-executor325 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+0x1e9/0x30e lib/dump_stack.c:118
 print_address_description+0x74/0x5c0 mm/kasan/report.c:374
 __kasan_report+0x14b/0x1c0 mm/kasan/report.c:506
 kasan_report+0x25/0x50 mm/kasan/common.c:641
 check_memory_region_inline mm/kasan/generic.c:182 [inline]
 check_memory_region+0x2a5/0x2e0 mm/kasan/generic.c:192
 memcpy+0x38/0x50 mm/kasan/common.c:128
 tcindex_set_parms net/sched/cls_tcindex.c:455 [inline]
 tcindex_change+0x1c61/0x27b0 net/sched/cls_tcindex.c:518
 tc_new_tfilter+0x1490/0x2f50 net/sched/cls_api.c:2103
 rtnetlink_rcv_msg+0x8fb/0xd40 net/core/rtnetlink.c:5427
 netlink_rcv_skb+0x190/0x3a0 net/netlink/af_netlink.c:2478
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x786/0x940 net/netlink/af_netlink.c:1329
 netlink_sendmsg+0xa57/0xd70 net/netlink/af_netlink.c:1918
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg net/socket.c:672 [inline]
 ____sys_sendmsg+0x4f9/0x7c0 net/socket.c:2343
 ___sys_sendmsg net/socket.c:2397 [inline]
 __sys_sendmsg+0x1ed/0x290 net/socket.c:2430
 do_syscall_64+0xf3/0x1b0 arch/x86/entry/common.c:294
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:00007ffe907a5898 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00000000004a2650 RCX: 0000000000440e79
RDX: 0000000000000000 RSI: 00000000200001c0 RDI: 0000000000000003
RBP: 00007ffe907a58a0 R08: 0000000120080522 R09: 0000000120080522
R10: 0000000120080522 R11: 0000000000000246 R12: 00000000004a2650
R13: 0000000000402410 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 7368:
 save_stack mm/kasan/common.c:72 [inline]
 set_track mm/kasan/common.c:80 [inline]
 __kasan_kmalloc+0x118/0x1c0 mm/kasan/common.c:515
 __do_kmalloc mm/slab.c:3656 [inline]
 __kmalloc+0x24b/0x330 mm/slab.c:3665
 kmalloc include/linux/slab.h:560 [inline]
 kzalloc+0x1d/0x40 include/linux/slab.h:669
 lsm_cred_alloc security/security.c:532 [inline]
 security_prepare_creds+0x46/0x220 security/security.c:1586
 prepare_creds+0x3dc/0x590 kernel/cred.c:285
 copy_creds+0x130/0x6b0 kernel/cred.c:355
 copy_process+0x8e5/0x5560 kernel/fork.c:1953
 _do_fork+0x134/0x650 kernel/fork.c:2430
 __do_sys_clone kernel/fork.c:2585 [inline]
 __se_sys_clone kernel/fork.c:2566 [inline]
 __x64_sys_clone+0x208/0x250 kernel/fork.c:2566
 do_syscall_64+0xf3/0x1b0 arch/x86/entry/common.c:294

Freed by task 7471:
 save_stack mm/kasan/common.c:72 [inline]
 set_track mm/kasan/common.c:80 [inline]
 kasan_set_free_info mm/kasan/common.c:337 [inline]
 __kasan_slab_free+0x12e/0x1e0 mm/kasan/common.c:476
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x10a/0x220 mm/slab.c:3757
 security_cred_free+0xbf/0x100 security/security.c:1580
 put_cred_rcu+0xca/0x350 kernel/cred.c:114
 rcu_do_batch kernel/rcu/tree.c:2186 [inline]
 rcu_core+0x7e4/0x1080 kernel/rcu/tree.c:2410
 __do_softirq+0x268/0x7c5 kernel/softirq.c:292

The buggy address belongs to the object at ffff8880a7596300
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 48 bytes inside of
 192-byte region [ffff8880a7596300, ffff8880a75963c0)
The buggy address belongs to the page:
page:ffffea00029d6580 refcount:1 mapcount:0 mapping:ffff8880aa400000 index:0xffff8880a7596100
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea000277cb88 ffffea0002a11948 ffff8880aa400000
raw: ffff8880a7596100 ffff8880a7596000 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a7596200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880a7596280: 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880a7596300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a7596380: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8880a7596400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/03/18 15:15 upstream ac309e7744be 97bc55ce .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/03/18 03:28 upstream ac309e7744be 97bc55ce .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/03/18 02:07 upstream ac309e7744be 97bc55ce .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/03/17 21:05 upstream fb33c6510d55 749688d2 .config console log report syz C ci-upstream-kasan-gce-smack-root
* Struck through repros no longer work on HEAD.