syzbot


KASAN: use-after-free Read in inet_gifconf

Status: fixed on 2020/04/15 17:19
Subsystems: net
[Documentation on labels]
Fix commit: 44bfa9c5e5f0 net: rtnetlink: fix bugs in rtnl_alt_ifname()
First crash: 1525d, last: 1519d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __in_dev_get_rtnl include/linux/inetdevice.h:236 [inline]
BUG: KASAN: use-after-free in inet_gifconf+0x47e/0x490 net/ipv4/devinet.c:1243
Read of size 8 at addr ffff88804e37c318 by task syz-executor.5/11148

CPU: 0 PID: 11148 Comm: syz-executor.5 Not tainted 5.6.0-rc2-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_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135
 __in_dev_get_rtnl include/linux/inetdevice.h:236 [inline]
 inet_gifconf+0x47e/0x490 net/ipv4/devinet.c:1243
 dev_ifconf+0xd0/0x230 net/core/dev_ioctl.c:80
 sock_do_ioctl+0x260/0x2f0 net/socket.c:1067
 sock_ioctl+0x3ed/0x790 net/socket.c:1204
 vfs_ioctl fs/ioctl.c:47 [inline]
 ksys_ioctl+0x123/0x180 fs/ioctl.c:763
 __do_sys_ioctl fs/ioctl.c:772 [inline]
 __se_sys_ioctl fs/ioctl.c:770 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:770
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45c429
Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fe12d8cfc78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fe12d8d06d4 RCX: 000000000045c429
RDX: 0000000000400200 RSI: 0000000000008912 RDI: 0000000000000003
RBP: 000000000076bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 000000000000040e R14: 00000000004c66b9 R15: 000000000076bf2c

Allocated by task 9627:
 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_kmalloc+0x9/0x10 mm/kasan/common.c:529
 __do_kmalloc_node mm/slab.c:3616 [inline]
 __kmalloc_node+0x4e/0x70 mm/slab.c:3623
 kmalloc_node include/linux/slab.h:578 [inline]
 kvmalloc_node+0x68/0x100 mm/util.c:574
 kvmalloc include/linux/mm.h:645 [inline]
 kvzalloc include/linux/mm.h:653 [inline]
 alloc_netdev_mqs+0x98/0xe40 net/core/dev.c:9797
 rtnl_create_link+0x22d/0xaf0 net/core/rtnetlink.c:3047
 __rtnl_newlink+0xf9f/0x1790 net/core/rtnetlink.c:3309
 rtnl_newlink+0x69/0xa0 net/core/rtnetlink.c:3377
 rtnetlink_rcv_msg+0x45e/0xaf0 net/core/rtnetlink.c:5438
 netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477
 rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:5456
 netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
 netlink_unicast+0x59e/0x7e0 net/netlink/af_netlink.c:1328
 netlink_sendmsg+0x91c/0xea0 net/netlink/af_netlink.c:1917
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:672
 __sys_sendto+0x262/0x380 net/socket.c:1998
 __do_sys_sendto net/socket.c:2010 [inline]
 __se_sys_sendto net/socket.c:2006 [inline]
 __x64_sys_sendto+0xe1/0x1a0 net/socket.c:2006
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 11118:
 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]
 kfree+0x10a/0x2c0 mm/slab.c:3757
 __netdev_name_node_alt_destroy+0x1ff/0x2a0 net/core/dev.c:322
 netdev_name_node_alt_destroy+0x57/0x80 net/core/dev.c:334
 rtnl_alt_ifname net/core/rtnetlink.c:3518 [inline]
 rtnl_linkprop.isra.0+0x575/0x6f0 net/core/rtnetlink.c:3567
 rtnl_dellinkprop+0x46/0x60 net/core/rtnetlink.c:3588
 rtnetlink_rcv_msg+0x45e/0xaf0 net/core/rtnetlink.c:5438
 netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477
 rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:5456
 netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
 netlink_unicast+0x59e/0x7e0 net/netlink/af_netlink.c:1328
 netlink_sendmsg+0x91c/0xea0 net/netlink/af_netlink.c:1917
 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

The buggy address belongs to the object at ffff88804e37c000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 792 bytes inside of
 4096-byte region [ffff88804e37c000, ffff88804e37d000)
The buggy address belongs to the page:
page:ffffea000138df00 refcount:1 mapcount:0 mapping:ffff8880aa402000 index:0x0 compound_mapcount: 0
flags: 0xfffe0000010200(slab|head)
raw: 00fffe0000010200 ffffea000138de88 ffffea000138df88 ffff8880aa402000
raw: 0000000000000000 ffff88804e37c000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88804e37c200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88804e37c280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88804e37c300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff88804e37c380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88804e37c400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (24):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/02/21 20:44 upstream ca7e1fd1026c 2ffa6679 .config console log report ci-upstream-kasan-gce
2020/02/20 09:04 upstream ca7e1fd1026c 81230308 .config console log report ci-upstream-kasan-gce-selinux-root
2020/02/20 07:41 upstream ca7e1fd1026c 81230308 .config console log report ci-upstream-kasan-gce-selinux-root
2020/02/19 05:06 upstream 0a44cac81050 135c18aa .config console log report ci-upstream-kasan-gce-selinux-root
2020/02/18 14:24 upstream b1da3acc781c 012fbc32 .config console log report ci-upstream-kasan-gce-smack-root
2020/02/18 02:01 upstream 11a48a5a18c6 1ce142dc .config console log report ci-upstream-kasan-gce-root
2020/02/17 11:26 upstream 11a48a5a18c6 2b411596 .config console log report ci-upstream-kasan-gce-root
2020/02/17 11:05 upstream 11a48a5a18c6 2b411596 .config console log report ci-upstream-kasan-gce
2020/02/17 11:04 upstream 11a48a5a18c6 2b411596 .config console log report ci-upstream-kasan-gce-smack-root
2020/02/17 11:01 upstream 11a48a5a18c6 2b411596 .config console log report ci-upstream-kasan-gce-selinux-root
2020/02/17 10:50 upstream 11a48a5a18c6 2b411596 .config console log report ci-upstream-kasan-gce-root
2020/02/17 10:40 upstream 11a48a5a18c6 2b411596 .config console log report ci-upstream-kasan-gce-smack-root
2020/02/16 22:08 upstream 11a48a5a18c6 1f448cd6 .config console log report ci-upstream-kasan-gce-smack-root
2020/02/16 21:40 upstream db70e26e33ee cf914200 .config console log report ci-upstream-kasan-gce
2020/02/16 10:40 upstream db70e26e33ee cf914200 .config console log report ci-upstream-kasan-gce-smack-root
2020/02/16 10:17 upstream db70e26e33ee cf914200 .config console log report ci-upstream-kasan-gce-selinux-root
2020/02/16 10:10 upstream db70e26e33ee cf914200 .config console log report ci-upstream-kasan-gce-smack-root
2020/02/16 09:46 upstream db70e26e33ee cf914200 .config console log report ci-upstream-kasan-gce-root
2020/02/16 09:06 upstream db70e26e33ee 5d7b90f1 .config console log report ci-upstream-kasan-gce-smack-root
2020/02/16 02:24 upstream 829e69446995 5d7b90f1 .config console log report ci-upstream-kasan-gce
2020/02/15 20:57 upstream 829e69446995 5d7b90f1 .config console log report ci-upstream-kasan-gce-root
2020/02/15 20:49 upstream 829e69446995 5d7b90f1 .config console log report ci-upstream-kasan-gce-smack-root
2020/02/15 18:25 upstream 2019fc96af22 5d7b90f1 .config console log report ci-upstream-kasan-gce-smack-root
2020/02/15 23:26 linux-next 9f01828e9e16 5d7b90f1 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.