KASAN: use-after-free Read in __smc_diag_dump

5 views
Skip to first unread message

syzbot

unread,
Jun 30, 2019, 9:50:07 AM6/30/19
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: f4cc0ed9 Linux 4.14.131
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=170d6bf9a00000
kernel config: https://syzkaller.appspot.com/x/.config?x=ab1953b2cdac00f5
dashboard link: https://syzkaller.appspot.com/bug?extid=ff70bd4c42a91c828268
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13fccf9da00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+ff70bd...@syzkaller.appspotmail.com

SELinux: unrecognized netlink message: protocol=4 nlmsg_type=0
sclass=netlink_tcpdiag_socket pig=6993 comm=syz-executor.0
SELinux: unrecognized netlink message: protocol=4 nlmsg_type=0
sclass=netlink_tcpdiag_socket pig=6993 comm=syz-executor.0
==================================================================
BUG: KASAN: use-after-free in smc_diag_msg_common_fill
net/smc/smc_diag.c:44 [inline]
BUG: KASAN: use-after-free in __smc_diag_dump.isra.0+0x16e0/0x17b0
net/smc/smc_diag.c:82
Read of size 8 at addr ffff8880871f4a60 by task syz-executor.0/6992

CPU: 1 PID: 6992 Comm: syz-executor.0 Not tainted 4.14.131 #25
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x138/0x19c lib/dump_stack.c:53
print_address_description.cold+0x7c/0x1dc mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report mm/kasan/report.c:409 [inline]
kasan_report.cold+0xa9/0x2af mm/kasan/report.c:393
__asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430
smc_diag_msg_common_fill net/smc/smc_diag.c:44 [inline]
__smc_diag_dump.isra.0+0x16e0/0x17b0 net/smc/smc_diag.c:82
smc_diag_dump+0x1e5/0x2a0 net/smc/smc_diag.c:170
netlink_dump+0x3fa/0xb10 net/netlink/af_netlink.c:2202
__netlink_dump_start+0x4ff/0x750 net/netlink/af_netlink.c:2299
netlink_dump_start include/linux/netlink.h:217 [inline]
smc_diag_handler_dump+0x1b7/0x200 net/smc/smc_diag.c:191
__sock_diag_cmd net/core/sock_diag.c:231 [inline]
sock_diag_rcv_msg+0x29e/0x3a0 net/core/sock_diag.c:263
netlink_rcv_skb+0x14f/0x3c0 net/netlink/af_netlink.c:2432
sock_diag_rcv+0x2b/0x40 net/core/sock_diag.c:274
netlink_unicast_kernel net/netlink/af_netlink.c:1286 [inline]
netlink_unicast+0x45d/0x780 net/netlink/af_netlink.c:1312
netlink_sendmsg+0x7c4/0xc60 net/netlink/af_netlink.c:1877
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xce/0x110 net/socket.c:656
kernel_sendmsg+0x44/0x50 net/socket.c:664
sock_no_sendpage+0x107/0x130 net/core/sock.c:2567
kernel_sendpage+0x92/0xf0 net/socket.c:3415
sock_sendpage+0x8b/0xc0 net/socket.c:871
pipe_to_sendpage+0x242/0x340 fs/splice.c:451
splice_from_pipe_feed fs/splice.c:502 [inline]
__splice_from_pipe+0x348/0x780 fs/splice.c:626
splice_from_pipe+0xf0/0x150 fs/splice.c:661
generic_splice_sendpage+0x3c/0x50 fs/splice.c:832
do_splice_from fs/splice.c:851 [inline]
do_splice fs/splice.c:1147 [inline]
SYSC_splice fs/splice.c:1402 [inline]
SyS_splice+0xd92/0x1430 fs/splice.c:1382
do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x459519
RSP: 002b:00007f0706b22c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000113
RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 0000000000459519
RDX: 0000000000000007 RSI: 0000000000000000 RDI: 0000000000000005
RBP: 000000000075bf20 R08: 0000000080000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f0706b236d4
R13: 00000000004c8a66 R14: 00000000004deb70 R15: 00000000ffffffff

Allocated by task 6992:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
save_stack+0x45/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc mm/kasan/kasan.c:551 [inline]
kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:529
kasan_slab_alloc+0xf/0x20 mm/kasan/kasan.c:489
kmem_cache_alloc+0x12e/0x780 mm/slab.c:3552
sock_alloc_inode+0x1d/0x260 net/socket.c:251
alloc_inode+0x64/0x180 fs/inode.c:209
new_inode_pseudo+0x19/0xf0 fs/inode.c:891
sock_alloc+0x41/0x280 net/socket.c:569
__sock_create+0x8f/0x620 net/socket.c:1239
sock_create_kern+0x3b/0x50 net/socket.c:1321
smc_create+0x109/0x300 net/smc/af_smc.c:1361
__sock_create+0x2f6/0x620 net/socket.c:1275
sock_create net/socket.c:1315 [inline]
SYSC_socket net/socket.c:1345 [inline]
SyS_socket+0xd3/0x170 net/socket.c:1325
do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 6990:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
save_stack+0x45/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0x75/0xc0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kmem_cache_free+0x83/0x2b0 mm/slab.c:3758
sock_destroy_inode+0x54/0x60 net/socket.c:281
destroy_inode+0xc2/0x120 fs/inode.c:266
evict+0x3e6/0x630 fs/inode.c:571
iput_final fs/inode.c:1516 [inline]
iput fs/inode.c:1543 [inline]
iput+0x471/0x900 fs/inode.c:1528
__sock_release+0x236/0x2b0 net/socket.c:615
sock_release+0x18/0x20 net/socket.c:623
smc_release+0x23b/0x630 net/smc/af_smc.c:141
__sock_release+0xce/0x2b0 net/socket.c:602
sock_close+0x1b/0x30 net/socket.c:1139
__fput+0x275/0x7a0 fs/file_table.c:210
____fput+0x16/0x20 fs/file_table.c:244
task_work_run+0x114/0x190 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:191 [inline]
exit_to_usermode_loop+0x1da/0x220 arch/x86/entry/common.c:164
prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
do_syscall_64+0x4bc/0x640 arch/x86/entry/common.c:297
entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff8880871f4a40
which belongs to the cache sock_inode_cache of size 992
The buggy address is located 32 bytes inside of
992-byte region [ffff8880871f4a40, ffff8880871f4e20)
The buggy address belongs to the page:
page:ffffea00021c7d00 count:1 mapcount:0 mapping:ffff8880871f4140
index:0xffff8880871f4ffd
flags: 0x1fffc0000000100(slab)
raw: 01fffc0000000100 ffff8880871f4140 ffff8880871f4ffd 0000000100000003
raw: ffffea00021c6be0 ffffea00021c19a0 ffff88821b7573c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880871f4900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880871f4980: fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
> ffff8880871f4a00: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
^
ffff8880871f4a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880871f4b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches
Reply all
Reply to author
Forward
0 new messages