syzbot


KASAN: use-after-free Read in sctp_sock_dump
Status: upstream: reported syz repro on 2019/10/28 15:32
Reported-by: syzbot+e5b57b8780297657b25b@syzkaller.appspotmail.com
First crash: 943d, last: 789d

Cause bisection: introduced by (bisect log) :
commit 61086f391044fd587af9d70a9b8f6f800dd474ba
Author: Vlad Buslov <vladbu@mellanox.com>
Date: Fri Aug 2 19:21:56 2019 +0000

  net/mlx5e: Protect encap hash table with mutex

Crash: KASAN: use-after-free Read in sctp_hash_cmp (log)
Repro: syz .config

Fix bisection: failed (bisect log)
similar bugs (1):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Read in sctp_sock_dump syz error 1 247d 838d 0/1 upstream: reported syz repro on 2020/02/10 11:26
Patch testing requests:
Created Duration User Patch Repo Result
2021/10/11 05:52 16m phind.uet@gmail.com linux-next OK

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in sctp_sock_dump+0xa56/0xad0 net/sctp/diag.c:307
Read of size 8 at addr ffff88809117e4a0 by task syz-executor.0/23155

CPU: 0 PID: 23155 Comm: syz-executor.0 Not tainted 5.6.0-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+0x188/0x20d lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd3/0x315 mm/kasan/report.c:374
 __kasan_report.cold+0x1a/0x32 mm/kasan/report.c:506
 kasan_report+0xe/0x20 mm/kasan/common.c:641
 sctp_sock_dump+0xa56/0xad0 net/sctp/diag.c:307
 sctp_for_each_transport+0x27c/0x310 net/sctp/socket.c:5458
 sctp_diag_dump+0x2fd/0x3f0 net/sctp/diag.c:509
 __inet_diag_dump+0x99/0x130 net/ipv4/inet_diag.c:1049
 netlink_dump+0x515/0xf30 net/netlink/af_netlink.c:2245
 __netlink_dump_start+0x648/0x910 net/netlink/af_netlink.c:2353
 netlink_dump_start include/linux/netlink.h:246 [inline]
 inet_diag_handler_cmd+0x23f/0x300 net/ipv4/inet_diag.c:1170
 __sock_diag_cmd net/core/sock_diag.c:233 [inline]
 sock_diag_rcv_msg+0x2fe/0x3e0 net/core/sock_diag.c:264
 netlink_rcv_skb+0x15a/0x410 net/netlink/af_netlink.c:2469
 sock_diag_rcv+0x26/0x40 net/core/sock_diag.c:275
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x537/0x740 net/netlink/af_netlink.c:1329
 netlink_sendmsg+0x882/0xe10 net/netlink/af_netlink.c:1918
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:672
 sock_write_iter+0x283/0x3c0 net/socket.c:1004
 call_write_iter include/linux/fs.h:1902 [inline]
 do_iter_readv_writev+0x59c/0x840 fs/read_write.c:693
 do_iter_write fs/read_write.c:998 [inline]
 do_iter_write+0x185/0x600 fs/read_write.c:979
 vfs_writev+0x1b3/0x2f0 fs/read_write.c:1071
 do_writev+0x279/0x2f0 fs/read_write.c:1114
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45c849
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:00007fd7dd721c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000014
RAX: ffffffffffffffda RBX: 00007fd7dd7226d4 RCX: 000000000045c849
RDX: 0000000000000001 RSI: 0000000020000000 RDI: 0000000000000006
RBP: 000000000076bfa0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 0000000000000d12 R14: 00000000004cb1d9 R15: 000000000076bfac

Allocated by task 23155:
 save_stack+0x1b/0x80 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+0xbf/0xd0 mm/kasan/common.c:488
 kmem_cache_alloc_trace+0x153/0x7d0 mm/slab.c:3551
 kmalloc include/linux/slab.h:555 [inline]
 kzalloc include/linux/slab.h:669 [inline]
 sctp_endpoint_new+0x72/0xc40 net/sctp/endpointola.c:134
 sctp_init_sock+0xcdf/0x1430 net/sctp/socket.c:5143
 inet6_create net/ipv6/af_inet6.c:253 [inline]
 inet6_create+0x9cb/0xf80 net/ipv6/af_inet6.c:107
 __sock_create+0x3cb/0x730 net/socket.c:1433
 sock_create net/socket.c:1484 [inline]
 __sys_socket+0xef/0x200 net/socket.c:1526
 __do_sys_socket net/socket.c:1535 [inline]
 __se_sys_socket net/socket.c:1533 [inline]
 __x64_sys_socket+0x6f/0xb0 net/socket.c:1533
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 23152:
 save_stack+0x1b/0x80 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+0xf7/0x140 mm/kasan/common.c:476
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x109/0x2b0 mm/slab.c:3757
 sctp_endpoint_destroy net/sctp/endpointola.c:220 [inline]
 sctp_endpoint_put+0x21d/0x2c0 net/sctp/endpointola.c:236
 sctp_destroy_sock+0x9c/0x3c0 net/sctp/socket.c:5196
 sctp_v6_destroy_sock+0x11/0x20 net/sctp/socket.c:9636
 sk_common_release+0x64/0x370 net/core/sock.c:3173
 sctp_close+0x4d2/0x8a0 net/sctp/socket.c:1536
 inet_release+0xe4/0x1f0 net/ipv4/af_inet.c:427
 inet6_release+0x4c/0x70 net/ipv6/af_inet6.c:470
 __sock_release+0xcd/0x280 net/socket.c:605
 sock_close+0x18/0x20 net/socket.c:1283
 __fput+0x2da/0x850 fs/file_table.c:280
 task_work_run+0x13f/0x1b0 kernel/task_work.c:113
 get_signal+0x2054/0x24e0 kernel/signal.c:2533
 do_signal+0x7e/0x13f0 arch/x86/kernel/signal.c:813
 exit_to_usermode_loop+0x26c/0x360 arch/x86/entry/common.c:160
 prepare_exit_to_usermode arch/x86/entry/common.c:195 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:278 [inline]
 do_syscall_64+0x6b1/0x7d0 arch/x86/entry/common.c:304
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809117e400
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 160 bytes inside of
 512-byte region [ffff88809117e400, ffff88809117e600)
The buggy address belongs to the page:
page:ffffea0002445f80 refcount:1 mapcount:0 mapping:ffff8880aa000a80 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea00024f7f88 ffffea00024e5308 ffff8880aa000a80
raw: 0000000000000000 ffff88809117e000 0000000100000004 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809117e380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88809117e400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88809117e480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff88809117e500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809117e580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (7):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-selinux-root 2020/03/30 23:10 upstream 7111951b8d49 c8d1cc20 .config log report syz
ci-upstream-kasan-gce-386 2019/10/28 08:16 upstream d6d5df1db6e9 25bb509e .config log report syz
ci-upstream-net-kasan-gce 2020/02/10 07:20 net-next fdfa3a6778b1 35f5e45e .config log report syz
ci-upstream-linux-next-kasan-gce-root 2019/11/20 11:54 linux-next 5d1131b4d61e f4b7ed07 .config log report syz
ci-upstream-net-kasan-gce 2020/03/12 04:56 net-next 314a9cbbfb1d e7caca8e .config log report
ci-upstream-net-kasan-gce 2020/02/10 06:04 net-next fdfa3a6778b1 35f5e45e .config log report
ci-upstream-net-kasan-gce 2020/02/07 00:19 net-next 33b40134e5cf c91cbc9d .config log report