syzbot


KASAN: use-after-free Read in cma_acquire_dev

Status: fixed on 2019/02/21 08:43
Subsystems: rdma
[Documentation on labels]
Reported-by: syzbot+908eac39ffdc39221032@syzkaller.appspotmail.com
Fix commit: 5fe23f262e05 ucma: fix a use-after-free in ucma_resolve_ip()
First crash: 2111d, last: 2111d
Discussions (1)
Title Replies (including bot) Last reply
KASAN: use-after-free Read in cma_acquire_dev 1 (2) 2019/02/20 15:26

Sample crash report:
netlink: 4 bytes leftover after parsing attributes in process `syz-executor0'.
QAT: Invalid ioctl
capability: warning: `syz-executor0' uses deprecated v2 capabilities in a way that may be insecure
==================================================================
BUG: KASAN: use-after-free in rdma_ip2gid include/rdma/ib_addr.h:143 [inline]
BUG: KASAN: use-after-free in cma_acquire_dev+0xe56/0xea0 drivers/infiniband/core/cma.c:654
Read of size 2 at addr ffff88019c561360 by task syz-executor2/8894

CPU: 1 PID: 8894 Comm: syz-executor2 Not tainted 4.18.0-rc3+ #131
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+0x1c9/0x2b4 lib/dump_stack.c:113
 print_address_description+0x6c/0x20b mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
 __asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:431
 rdma_ip2gid include/rdma/ib_addr.h:143 [inline]
 cma_acquire_dev+0xe56/0xea0 drivers/infiniband/core/cma.c:654
 rdma_bind_addr+0x248/0x23b0 drivers/infiniband/core/cma.c:3388
 cma_bind_addr drivers/infiniband/core/cma.c:2930 [inline]
 rdma_resolve_addr+0x500/0x28a0 drivers/infiniband/core/cma.c:2942
 ucma_resolve_ip+0x242/0x2a0 drivers/infiniband/core/ucma.c:711
 ucma_write+0x336/0x420 drivers/infiniband/core/ucma.c:1680
 __vfs_write+0x117/0x9f0 fs/read_write.c:485
 vfs_write+0x1f8/0x560 fs/read_write.c:549
 ksys_write+0x101/0x260 fs/read_write.c:598
 __do_sys_write fs/read_write.c:610 [inline]
 __se_sys_write fs/read_write.c:607 [inline]
 __x64_sys_write+0x73/0xb0 fs/read_write.c:607
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x455ba9
Code: 1d ba 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 eb b9 fb ff c3 66 2e 0f 1f 84 00 00 00 00 
RSP: 002b:00007fb04c987c68 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fb04c9886d4 RCX: 0000000000455ba9
RDX: 0000000000000048 RSI: 00000000200002c0 RDI: 0000000000000015
RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 00000000004c7f98 R14: 00000000004d4160 R15: 0000000000000000

Allocated by task 8894:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc4/0xe0 mm/kasan/kasan.c:553
 kmem_cache_alloc_trace+0x152/0x780 mm/slab.c:3620
 kmalloc include/linux/slab.h:513 [inline]
 kzalloc include/linux/slab.h:707 [inline]
 __rdma_create_id+0xdf/0x720 drivers/infiniband/core/cma.c:780
 ucma_create_id+0x399/0x9d0 drivers/infiniband/core/ucma.c:502
 ucma_write+0x336/0x420 drivers/infiniband/core/ucma.c:1680
 __vfs_write+0x117/0x9f0 fs/read_write.c:485
 vfs_write+0x1f8/0x560 fs/read_write.c:549
 ksys_write+0x101/0x260 fs/read_write.c:598
 __do_sys_write fs/read_write.c:610 [inline]
 __se_sys_write fs/read_write.c:607 [inline]
 __x64_sys_write+0x73/0xb0 fs/read_write.c:607
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8905:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xd9/0x260 mm/slab.c:3813
 rdma_destroy_id+0x8cd/0xe60 drivers/infiniband/core/cma.c:1703
 ucma_close+0x100/0x300 drivers/infiniband/core/ucma.c:1759
 __fput+0x355/0x8b0 fs/file_table.c:209
 ____fput+0x15/0x20 fs/file_table.c:243
 task_work_run+0x1ec/0x2a0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:192 [inline]
 exit_to_usermode_loop+0x313/0x370 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+0x6be/0x820 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88019c561340
 which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 32 bytes inside of
 2048-byte region [ffff88019c561340, ffff88019c561b40)
The buggy address belongs to the page:
page:ffffea0006715800 count:1 mapcount:0 mapping:ffff8801da800c40 index:0xffff88019c560240 compound_mapcount: 0
flags: 0x2fffc0000008100(slab|head)
raw: 02fffc0000008100 ffffea00066fb108 ffffea000670dc08 ffff8801da800c40
raw: ffff88019c560240 ffff88019c560240 0000000100000002 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88019c561200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88019c561280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88019c561300: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                                       ^
 ffff88019c561380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88019c561400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/07/06 05:27 upstream fc36def997cf d3b2a0e2 .config console log report ci-upstream-kasan-gce
* Struck through repros no longer work on HEAD.