syzbot


KASAN: use-after-free Read in __smc_diag_dump

Status: fixed on 2019/03/06 07:43
Subsystems: net s390
[Documentation on labels]
Reported-by: syzbot+fbd1e5476e4c94c7b34e@syzkaller.appspotmail.com
Fix commit: 26d92e951fe0 smc: move unhash as early as possible in smc_release()
First crash: 1941d, last: 1925d
Discussions (4)
Title Replies (including bot) Last reply
[PATCH 4.19 00/99] 4.19.17-stable review 109 (109) 2019/04/22 19:40
[PATCH 4.20 000/111] 4.20.4-stable review 120 (120) 2019/01/23 06:43
[Patch net] smc: move unhash as early as possible in smc_release() 5 (5) 2019/01/07 19:40
KASAN: use-after-free Read in __smc_diag_dump 0 (1) 2019/01/02 10:41
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Read in __smc_diag_dump syz inconclusive 6 1358d 1759d 0/1 upstream: reported syz repro on 2019/06/30 13:50

Sample crash report:
IPVS: ftp: loaded support on port[0] = 21
IPVS: ftp: loaded support on port[0] = 21
IPVS: ftp: loaded support on port[0] = 21
IPVS: ftp: loaded support on port[0] = 21
==================================================================
BUG: KASAN: use-after-free in smc_diag_msg_common_fill net/smc/smc_diag.c:43 [inline]
BUG: KASAN: use-after-free in __smc_diag_dump.isra.0+0x283c/0x2ba0 net/smc/smc_diag.c:93
Read of size 8 at addr ffff88809d3ce9a0 by task syz-executor0/8536

CPU: 0 PID: 8536 Comm: syz-executor0 Not tainted 5.0.0-rc1+ #21
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+0x1db/0x2d0 lib/dump_stack.c:113
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:187
 kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135
 smc_diag_msg_common_fill net/smc/smc_diag.c:43 [inline]
 __smc_diag_dump.isra.0+0x283c/0x2ba0 net/smc/smc_diag.c:93
 smc_diag_dump_proto.isra.0+0x2e7/0x3c0 net/smc/smc_diag.c:211
 smc_diag_dump+0x27/0x80 net/smc/smc_diag.c:225
 netlink_dump+0x5f2/0x1070 net/netlink/af_netlink.c:2244
 __netlink_dump_start+0x5b4/0x7e0 net/netlink/af_netlink.c:2352
 netlink_dump_start include/linux/netlink.h:225 [inline]
 smc_diag_handler_dump+0x2a7/0x350 net/smc/smc_diag.c:242
 __sock_diag_cmd net/core/sock_diag.c:232 [inline]
 sock_diag_rcv_msg+0x322/0x410 net/core/sock_diag.c:263
 netlink_rcv_skb+0x17d/0x410 net/netlink/af_netlink.c:2477
 sock_diag_rcv+0x2b/0x40 net/core/sock_diag.c:274
 netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
 netlink_unicast+0x574/0x770 net/netlink/af_netlink.c:1336
 netlink_sendmsg+0xa05/0xf90 net/netlink/af_netlink.c:1917
 sock_sendmsg_nosec net/socket.c:621 [inline]
 sock_sendmsg+0xdd/0x130 net/socket.c:631
 ___sys_sendmsg+0x7ec/0x910 net/socket.c:2116
 __sys_sendmsg+0x112/0x270 net/socket.c:2154
 __do_sys_sendmsg net/socket.c:2163 [inline]
 __se_sys_sendmsg net/socket.c:2161 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2161
 do_syscall_64+0x1a3/0x800 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x457ec9
Code: 6d b7 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 3b b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f129b9eac78 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000457ec9
RDX: 0000000000000000 RSI: 0000000020000040 RDI: 000000000000000e
RBP: 000000000073bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f129b9eb6d4
R13: 00000000004c52f9 R14: 00000000004d8d58 R15: 00000000ffffffff

Allocated by task 8537:
 save_stack+0x45/0xd0 mm/kasan/common.c:73
 set_track mm/kasan/common.c:85 [inline]
 __kasan_kmalloc mm/kasan/common.c:496 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:469
 kasan_kmalloc mm/kasan/common.c:504 [inline]
 kasan_slab_alloc+0xf/0x20 mm/kasan/common.c:411
 kmem_cache_alloc+0x12d/0x710 mm/slab.c:3543
 sock_alloc_inode+0x1d/0x260 net/socket.c:244
 alloc_inode+0x66/0x190 fs/inode.c:210
 new_inode_pseudo+0x71/0x1b0 fs/inode.c:906
 sock_alloc+0x41/0x270 net/socket.c:547
 __sock_create+0x173/0x930 net/socket.c:1241
 sock_create_kern+0x3b/0x50 net/socket.c:1323
 smc_create+0x17f/0x3c0 net/smc/af_smc.c:1921
 __sock_create+0x532/0x930 net/socket.c:1277
 sock_create net/socket.c:1317 [inline]
 __sys_socket+0x106/0x260 net/socket.c:1347
 __do_sys_socket net/socket.c:1356 [inline]
 __se_sys_socket net/socket.c:1354 [inline]
 __x64_sys_socket+0x73/0xb0 net/socket.c:1354
 do_syscall_64+0x1a3/0x800 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8535:
 save_stack+0x45/0xd0 mm/kasan/common.c:73
 set_track mm/kasan/common.c:85 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:458
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:466
 __cache_free mm/slab.c:3487 [inline]
 kmem_cache_free+0x86/0x260 mm/slab.c:3749
 sock_destroy_inode+0x4f/0x60 net/socket.c:272
 destroy_inode+0x14f/0x1f0 fs/inode.c:267
 evict+0x5c3/0x940 fs/inode.c:575
 iput_final fs/inode.c:1550 [inline]
 iput fs/inode.c:1576 [inline]
 iput+0x67e/0xae0 fs/inode.c:1562
 __sock_release+0x1e6/0x250 net/socket.c:590
 sock_release+0x18/0x20 net/socket.c:598
 smc_release+0x29c/0x9c0 net/smc/af_smc.c:155
 __sock_release+0xd3/0x250 net/socket.c:579
 sock_close+0x1b/0x30 net/socket.c:1141
 __fput+0x3c5/0xb10 fs/file_table.c:278
 ____fput+0x16/0x20 fs/file_table.c:309
 task_work_run+0x1f4/0x2b0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop+0x32a/0x3b0 arch/x86/entry/common.c:166
 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
 do_syscall_64+0x696/0x800 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809d3ce980
 which belongs to the cache sock_inode_cache(17:syz0) of size 976
The buggy address is located 32 bytes inside of
 976-byte region [ffff88809d3ce980, ffff88809d3ced50)
The buggy address belongs to the page:
page:ffffea000274f380 count:1 mapcount:0 mapping:ffff88809a28d780 index:0xffff88809d3ceffd
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea00024b9c08 ffffea00025f8788 ffff88809a28d780
raw: ffff88809d3ceffd ffff88809d3ce080 0000000100000003 ffff8880a000a0c0
page dumped because: kasan: bad access detected
page->mem_cgroup:ffff8880a000a0c0

Memory state around the buggy address:
 ffff88809d3ce880: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc
 ffff88809d3ce900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88809d3ce980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff88809d3cea00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809d3cea80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (34):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/01/12 13:20 upstream 4b3c31c8d4dd c3f3344c .config console log report syz ci-upstream-kasan-gce-selinux-root
2019/01/12 13:06 upstream 4b3c31c8d4dd c3f3344c .config console log report syz ci-upstream-kasan-gce
2019/01/07 02:56 upstream 574823bfab82 ee332608 .config console log report syz ci-upstream-kasan-gce
2018/12/31 08:25 upstream 195303136f19 2b42fdc8 .config console log report syz ci-upstream-kasan-gce-smack-root
2018/12/30 14:41 upstream 195303136f19 9942de5f .config console log report syz ci-upstream-kasan-gce-smack-root
2018/12/30 14:03 upstream 195303136f19 9942de5f .config console log report syz ci-upstream-kasan-gce
2018/12/29 19:21 upstream 903b77c63167 a40793d7 .config console log report syz ci-upstream-kasan-gce-smack-root
2018/12/31 08:26 upstream 195303136f19 2b42fdc8 .config console log report syz ci-upstream-kasan-gce-386
2018/12/30 15:45 upstream 195303136f19 9942de5f .config console log report syz ci-upstream-kasan-gce-386
2018/12/29 17:49 upstream 903b77c63167 a40793d7 .config console log report syz ci-upstream-kasan-gce-386
2018/12/29 18:42 net-old 7418e6520f22 a40793d7 .config console log report syz ci-upstream-net-this-kasan-gce
2018/12/29 17:19 net-next-old b71acb0e3721 a40793d7 .config console log report syz ci-upstream-net-kasan-gce
2019/01/14 20:15 upstream c962cb323ec2 95485883 .config console log report ci-upstream-kasan-gce
2019/01/07 01:23 upstream 574823bfab82 ee332608 .config console log report ci-upstream-kasan-gce-root
2019/01/02 12:50 upstream 8e143b90e4d4 f0491811 .config console log report ci-upstream-kasan-gce-root
2019/01/02 03:33 upstream 28e8c4bc8eb4 3d85f48c .config console log report ci-upstream-kasan-gce
2018/12/31 07:50 upstream 195303136f19 2b42fdc8 .config console log report ci-upstream-kasan-gce-root
2019/01/08 16:54 bpf 2dc0f02da14e 37dd2683 .config console log report ci-upstream-bpf-kasan-gce
2019/01/07 09:29 net-old d4a7e9bb74b5 ee332608 .config console log report ci-upstream-net-this-kasan-gce
2019/01/07 04:46 net-old d4a7e9bb74b5 ee332608 .config console log report ci-upstream-net-this-kasan-gce
2018/12/30 11:17 net-old 0d9c9a238faf 35e3f847 .config console log report ci-upstream-net-this-kasan-gce
2019/01/14 18:35 net-next-old b71acb0e3721 95485883 .config console log report ci-upstream-net-kasan-gce
2019/01/13 23:13 bpf-next b71acb0e3721 c3f3344c .config console log report ci-upstream-bpf-next-kasan-gce
2019/01/13 12:50 bpf-next b71acb0e3721 c3f3344c .config console log report ci-upstream-bpf-next-kasan-gce
2019/01/13 08:09 bpf-next b71acb0e3721 c3f3344c .config console log report ci-upstream-bpf-next-kasan-gce
2019/01/11 14:18 net-next-old b71acb0e3721 c3f3344c .config console log report ci-upstream-net-kasan-gce
2019/01/09 23:57 net-next-old b71acb0e3721 45c0c1b1 .config console log report ci-upstream-net-kasan-gce
2019/01/08 10:01 net-next-old b71acb0e3721 37dd2683 .config console log report ci-upstream-net-kasan-gce
2019/01/08 05:44 net-next-old b71acb0e3721 69d69aa9 .config console log report ci-upstream-net-kasan-gce
2019/01/07 19:50 net-next-old b71acb0e3721 69d69aa9 .config console log report ci-upstream-net-kasan-gce
2019/01/04 15:46 net-next-old b71acb0e3721 0127e3ba .config console log report ci-upstream-net-kasan-gce
2019/01/04 13:32 net-next-old b71acb0e3721 7da23925 .config console log report ci-upstream-net-kasan-gce
2019/01/03 08:29 net-next-old b71acb0e3721 06a2b89f .config console log report ci-upstream-net-kasan-gce
2019/01/02 05:01 net-next-old b71acb0e3721 3d85f48c .config console log report ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.