syzbot


KASAN: use-after-free Read in ethnl_update_bitset32

Status: fixed on 2020/04/15 17:19
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+709b7a64d57978247e44@syzkaller.appspotmail.com
Fix commit: e34f1753eebc ethtool: limit bitset size
First crash: 1518d, last: 1509d
Cause bisection: introduced by (bisect log) :
commit bfbcfe2032e70bd8598d680d39ac177d507e39ac
Author: Michal Kubecek <mkubecek@suse.cz>
Date: Fri Dec 27 14:56:13 2019 +0000

  ethtool: set link modes related data with LINKMODES_SET request

Crash: KASAN: use-after-free Read in ethnl_update_bitset32 (log)
Repro: C syz .config
  
Discussions (2)
Title Replies (including bot) Last reply
[PATCH net] ethtool: limit bitset size 2 (2) 2020/02/26 19:28
KASAN: use-after-free Read in ethnl_update_bitset32 0 (2) 2020/02/24 11:46

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in ethnl_bitmap32_not_zero net/ethtool/bitset.c:112 [inline]
BUG: KASAN: use-after-free in ethnl_compact_sanity_checks net/ethtool/bitset.c:529 [inline]
BUG: KASAN: use-after-free in ethnl_update_bitset32.part.0+0x8db/0x1820 net/ethtool/bitset.c:572
Read of size 4 at addr ffff8880a81b743c by task syz-executor545/10450

CPU: 0 PID: 10450 Comm: syz-executor545 Not tainted 5.6.0-rc3-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+0x197/0x210 lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
 __kasan_report.cold+0x1b/0x32 mm/kasan/report.c:506
 kasan_report+0x12/0x20 mm/kasan/common.c:641
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/generic_report.c:134
 ethnl_bitmap32_not_zero net/ethtool/bitset.c:112 [inline]
 ethnl_compact_sanity_checks net/ethtool/bitset.c:529 [inline]
 ethnl_update_bitset32.part.0+0x8db/0x1820 net/ethtool/bitset.c:572
 ethnl_update_bitset32 net/ethtool/bitset.c:562 [inline]
 ethnl_update_bitset+0x4d/0x67 net/ethtool/bitset.c:734
 ethnl_update_linkmodes net/ethtool/linkmodes.c:303 [inline]
 ethnl_set_linkmodes+0x461/0xc30 net/ethtool/linkmodes.c:357
 genl_family_rcv_msg_doit net/netlink/genetlink.c:672 [inline]
 genl_family_rcv_msg net/netlink/genetlink.c:717 [inline]
 genl_rcv_msg+0x67d/0xea0 net/netlink/genetlink.c:734
 netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2478
 genl_rcv+0x29/0x40 net/netlink/genetlink.c:745
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x59e/0x7e0 net/netlink/af_netlink.c:1329
 netlink_sendmsg+0x91c/0xea0 net/netlink/af_netlink.c:1918
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:672
 ____sys_sendmsg+0x753/0x880 net/socket.c:2343
 ___sys_sendmsg+0x100/0x170 net/socket.c:2397
 __sys_sendmsg+0x105/0x1d0 net/socket.c:2430
 __do_sys_sendmsg net/socket.c:2439 [inline]
 __se_sys_sendmsg net/socket.c:2437 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2437
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x445b39
Code: e8 ac cb 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 cc fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fff992b8188 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000445b39
RDX: 0000000000000000 RSI: 0000000020000240 RDI: 0000000000000003
RBP: 0000000000000000 R08: 0000000000000000 R09: 00000000bb1414ac
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000018e9e
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 10232:
 save_stack+0x23/0x90 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+0xcf/0xe0 mm/kasan/common.c:488
 kasan_slab_alloc+0xf/0x20 mm/kasan/common.c:523
 slab_post_alloc_hook mm/slab.h:584 [inline]
 slab_alloc mm/slab.c:3320 [inline]
 kmem_cache_alloc+0x121/0x710 mm/slab.c:3484
 getname_flags fs/namei.c:138 [inline]
 getname_flags+0xd6/0x5b0 fs/namei.c:128
 getname+0x1a/0x20 fs/namei.c:209
 do_sys_openat2+0x45c/0x7e0 fs/open.c:1143
 do_sys_open+0xf2/0x180 fs/open.c:1165
 ksys_open include/linux/syscalls.h:1386 [inline]
 __do_sys_open fs/open.c:1171 [inline]
 __se_sys_open fs/open.c:1169 [inline]
 __x64_sys_open+0x7e/0xc0 fs/open.c:1169
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 10232:
 save_stack+0x23/0x90 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+0x102/0x150 mm/kasan/common.c:476
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:485
 __cache_free mm/slab.c:3426 [inline]
 kmem_cache_free+0x86/0x320 mm/slab.c:3694
 putname+0xef/0x130 fs/namei.c:259
 do_sys_openat2+0x4c7/0x7e0 fs/open.c:1158
 do_sys_open+0xf2/0x180 fs/open.c:1165
 ksys_open include/linux/syscalls.h:1386 [inline]
 __do_sys_open fs/open.c:1171 [inline]
 __se_sys_open fs/open.c:1169 [inline]
 __x64_sys_open+0x7e/0xc0 fs/open.c:1169
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880a81b6b40
 which belongs to the cache names_cache of size 4096
The buggy address is located 2300 bytes inside of
 4096-byte region [ffff8880a81b6b40, ffff8880a81b7b40)
The buggy address belongs to the page:
page:ffffea0002a06d80 refcount:1 mapcount:0 mapping:ffff88821bc50a80 index:0x0 compound_mapcount: 0
flags: 0xfffe0000010200(slab|head)
raw: 00fffe0000010200 ffffea000254d808 ffffea00025b3b08 ffff88821bc50a80
raw: 0000000000000000 ffff8880a81b6b40 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a81b7300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a81b7380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a81b7400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                        ^
 ffff8880a81b7480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a81b7500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/02/28 04:29 upstream f8788d86ab28 59b57593 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/02/22 23:54 net-old 0c0ddd6ae47c 2c36e7a7 .config console log report syz C ci-upstream-net-this-kasan-gce
2020/02/22 22:34 net-next-old 732a0dee501f 2c36e7a7 .config console log report syz C ci-upstream-net-kasan-gce
2020/03/01 16:18 upstream 63623fd44972 c88c7b75 .config console log report ci-upstream-kasan-gce-selinux-root
2020/02/22 17:22 upstream 54dedb5b571d 2c36e7a7 .config console log report ci-qemu-upstream-386
2020/03/02 20:57 net-old 3614d05b5e6b c88c7b75 .config console log report ci-upstream-net-this-kasan-gce
* Struck through repros no longer work on HEAD.