syzbot


KASAN: use-after-free Read in iwcm_deref_id

Status: closed as dup on 2020/02/28 16:21
Reported-by: syzbot+cb0c054eabfba4342146@syzkaller.appspotmail.com
Fix commit: 810dbc69087b RDMA/iwcm: Fix iwcm work deallocation
First crash: 950d, last: 912d
Duplicate of (1):
Title Repro Cause bisect Fix bisect Count Last Reported
KASAN: use-after-free Read in rdma_listen (2) C done 354 913d 1282d

Sample crash report:
RBP: 000000000076bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000005
R13: 0000000000000cbe R14: 00000000004cea80 R15: 0000000000000007
==================================================================
BUG: KASAN: use-after-free in dealloc_work_entries drivers/infiniband/core/iwcm.c:162 [inline]
BUG: KASAN: use-after-free in free_cm_id drivers/infiniband/core/iwcm.c:202 [inline]
BUG: KASAN: use-after-free in iwcm_deref_id+0x1c4/0x1d0 drivers/infiniband/core/iwcm.c:215
Read of size 8 at addr ffff8880a2bd2978 by task syz-executor.2/12459

CPU: 1 PID: 12459 Comm: syz-executor.2 Not tainted 5.6.0-rc4-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
 dealloc_work_entries drivers/infiniband/core/iwcm.c:162 [inline]
 free_cm_id drivers/infiniband/core/iwcm.c:202 [inline]
 iwcm_deref_id+0x1c4/0x1d0 drivers/infiniband/core/iwcm.c:215
 destroy_cm_id+0x263/0x520 drivers/infiniband/core/iwcm.c:442
 cma_iw_listen drivers/infiniband/core/cma.c:2453 [inline]
 rdma_listen+0x623/0x910 drivers/infiniband/core/cma.c:3614
 cma_listen_on_dev+0x512/0x650 drivers/infiniband/core/cma.c:2501
 cma_listen_on_all drivers/infiniband/core/cma.c:2514 [inline]
 rdma_listen+0x739/0x910 drivers/infiniband/core/cma.c:3622
 ucma_listen+0x14d/0x1c0 drivers/infiniband/core/ucma.c:1092
 ucma_write+0x285/0x350 drivers/infiniband/core/ucma.c:1684
 __vfs_write+0x76/0x100 fs/read_write.c:494
 vfs_write+0x262/0x5c0 fs/read_write.c:558
 ksys_write+0x1e8/0x250 fs/read_write.c:611
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45c4a9
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:00007f6953755c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f69537566d4 RCX: 000000000045c4a9
RDX: 0000000000000010 RSI: 0000000020000000 RDI: 0000000000000003
RBP: 000000000076bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000005
R13: 0000000000000cbe R14: 00000000004cea80 R15: 0000000000000007

Allocated by task 12459:
 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]
 alloc_work_entries+0xa3/0x230 drivers/infiniband/core/iwcm.c:172
 iw_cm_listen+0x44/0x1e0 drivers/infiniband/core/iwcm.c:571
 cma_iw_listen drivers/infiniband/core/cma.c:2450 [inline]
 rdma_listen+0x5e2/0x910 drivers/infiniband/core/cma.c:3614
 cma_listen_on_dev+0x512/0x650 drivers/infiniband/core/cma.c:2501
 cma_listen_on_all drivers/infiniband/core/cma.c:2514 [inline]
 rdma_listen+0x739/0x910 drivers/infiniband/core/cma.c:3622
 ucma_listen+0x14d/0x1c0 drivers/infiniband/core/ucma.c:1092
 ucma_write+0x285/0x350 drivers/infiniband/core/ucma.c:1684
 __vfs_write+0x76/0x100 fs/read_write.c:494
 vfs_write+0x262/0x5c0 fs/read_write.c:558
 ksys_write+0x1e8/0x250 fs/read_write.c:611
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 12459:
 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
 dealloc_work_entries drivers/infiniband/core/iwcm.c:163 [inline]
 alloc_work_entries+0x1d8/0x230 drivers/infiniband/core/iwcm.c:174
 iw_cm_listen+0x44/0x1e0 drivers/infiniband/core/iwcm.c:571
 cma_iw_listen drivers/infiniband/core/cma.c:2450 [inline]
 rdma_listen+0x5e2/0x910 drivers/infiniband/core/cma.c:3614
 cma_listen_on_dev+0x512/0x650 drivers/infiniband/core/cma.c:2501
 cma_listen_on_all drivers/infiniband/core/cma.c:2514 [inline]
 rdma_listen+0x739/0x910 drivers/infiniband/core/cma.c:3622
 ucma_listen+0x14d/0x1c0 drivers/infiniband/core/ucma.c:1092
 ucma_write+0x285/0x350 drivers/infiniband/core/ucma.c:1684
 __vfs_write+0x76/0x100 fs/read_write.c:494
 vfs_write+0x262/0x5c0 fs/read_write.c:558
 ksys_write+0x1e8/0x250 fs/read_write.c:611
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880a2bd2800
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 376 bytes inside of
 512-byte region [ffff8880a2bd2800, ffff8880a2bd2a00)
The buggy address belongs to the page:
page:ffffea00028af480 refcount:1 mapcount:0 mapping:ffff8880aa000a80 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea00025cea08 ffffea000258a7c8 ffff8880aa000a80
raw: 0000000000000000 ffff8880a2bd2000 0000000100000004 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a2bd2800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a2bd2880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a2bd2900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                ^
 ffff8880a2bd2980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a2bd2a00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (15):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-root 2020/03/08 00:48 upstream 63849c8f4107 2e9971bb .config log report
ci-upstream-kasan-gce-smack-root 2020/03/05 14:35 upstream 63623fd44972 c88c7b75 .config log report
ci-upstream-kasan-gce-smack-root 2020/03/02 21:33 upstream 63623fd44972 c88c7b75 .config log report
ci-upstream-kasan-gce-smack-root 2020/02/29 07:11 upstream f8788d86ab28 59b57593 .config log report
ci-upstream-kasan-gce-selinux-root 2020/02/26 17:13 upstream f8788d86ab28 59b57593 .config log report
ci-upstream-kasan-gce-smack-root 2020/02/25 20:00 upstream f8788d86ab28 59b57593 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/04/03 21:12 linux-next 770fbb32d34e 5ed396e6 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/23 14:09 linux-next 770fbb32d34e 78267cec .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/21 06:55 linux-next 770fbb32d34e 2c31c529 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/09 02:49 linux-next 770fbb32d34e 2e9971bb .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/06 21:07 linux-next c99b17ac0399 c88c7b75 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/03 14:32 linux-next c99b17ac0399 c88c7b75 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/02 09:07 linux-next c99b17ac0399 c88c7b75 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/03/01 06:56 linux-next c99b17ac0399 c88c7b75 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/02/26 01:39 linux-next bdc5461b23ca 59b57593 .config log report
* Struck through repros no longer work on HEAD.