syzbot


KASAN: use-after-free Read in addr_handler (2)

Status: fixed on 2020/09/16 22:51
Subsystems: rdma
[Documentation on labels]
Reported-by: syzbot+a929647172775e335941@syzkaller.appspotmail.com
Fix commit: f6a9d47ae685 RDMA/cma: Execute rdma_cm destruction from a handler properly
First crash: 1644d, last: 1601d
Discussions (5)
Title Replies (including bot) Last reply
[PATCH 5.8 00/16] 5.8.9-rc1 review 23 (23) 2020/09/12 12:44
Re: KASAN: use-after-free Read in addr_handler (2) 5 (5) 2020/06/29 19:41
Re: [PATCH] RDMA/cma: Execute rdma_cm destruction from a handler properly 1 (1) 2020/06/27 02:38
Re: KASAN: use-after-free Read in addr_handler (2) 1 (1) 2020/06/27 00:45
KASAN: use-after-free Read in addr_handler (2) 0 (1) 2020/06/10 17:02
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in addr_handler (5) rdma 1 1170d 1166d 0/28 closed as dup on 2021/10/01 13:34
upstream KASAN: use-after-free Read in addr_handler (4) rdma 1 1186d 1182d 28/28 closed as dup on 2021/09/15 19:36
upstream KASAN: use-after-free Read in addr_handler rdma syz done 12 1707d 2189d 15/28 fixed on 2020/05/10 10:42
upstream KASAN: use-after-free Read in addr_handler (3) rdma 1 1327d 1324d 0/28 auto-closed as invalid on 2021/07/22 15:33

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __mutex_lock_common kernel/locking/mutex.c:938 [inline]
BUG: KASAN: use-after-free in __mutex_lock+0x10c9/0x10d0 kernel/locking/mutex.c:1103
Read of size 8 at addr ffff8880922883b0 by task kworker/u4:2/57

CPU: 0 PID: 57 Comm: kworker/u4:2 Not tainted 5.8.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: ib_addr process_one_req
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x18f/0x20d lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383
 __kasan_report mm/kasan/report.c:513 [inline]
 kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
 __mutex_lock_common kernel/locking/mutex.c:938 [inline]
 __mutex_lock+0x10c9/0x10d0 kernel/locking/mutex.c:1103
 addr_handler+0xb3/0x3f0 drivers/infiniband/core/cma.c:3140
 process_one_req+0xfa/0x680 drivers/infiniband/core/addr.c:645
 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269
 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415
 kthread+0x3b5/0x4a0 kernel/kthread.c:291
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293

Allocated by task 8866:
 save_stack+0x1b/0x40 mm/kasan/common.c:48
 set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494
 kmem_cache_alloc_trace+0x14f/0x2d0 mm/slab.c:3551
 kmalloc include/linux/slab.h:555 [inline]
 kzalloc include/linux/slab.h:669 [inline]
 __rdma_create_id+0x5b/0x560 drivers/infiniband/core/cma.c:867
 ucma_create_id+0x1d1/0x590 drivers/infiniband/core/ucma.c:508
 ucma_write+0x288/0x350 drivers/infiniband/core/ucma.c:1764
 vfs_write+0x2b0/0x6b0 fs/read_write.c:576
 ksys_write+0x1ee/0x250 fs/read_write.c:631
 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 8862:
 save_stack+0x1b/0x40 mm/kasan/common.c:48
 set_track mm/kasan/common.c:56 [inline]
 kasan_set_free_info mm/kasan/common.c:316 [inline]
 __kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x103/0x2c0 mm/slab.c:3757
 ucma_close+0x111/0x310 drivers/infiniband/core/ucma.c:1842
 __fput+0x33c/0x880 fs/file_table.c:281
 task_work_run+0xdd/0x190 kernel/task_work.c:135
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop arch/x86/entry/common.c:239 [inline]
 __prepare_exit_to_usermode+0x1e9/0x1f0 arch/x86/entry/common.c:269
 do_syscall_64+0x6c/0xe0 arch/x86/entry/common.c:393
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff888092288000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 944 bytes inside of
 2048-byte region [ffff888092288000, ffff888092288800)
The buggy address belongs to the page:
page:ffffea000248a200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea000248a588 ffffea000266fc48 ffff8880aa000e00
raw: 0000000000000000 ffff888092288000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888092288280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888092288300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888092288380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                     ^
 ffff888092288400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888092288480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/07/23 17:36 upstream d15be546031c 70c104a1 .config console log report ci-upstream-kasan-gce
2020/06/10 11:10 upstream 7ae77150d94d 860c4de9 .config console log report ci-upstream-kasan-gce
* Struck through repros no longer work on HEAD.