syzbot


KASAN: use-after-free Write in addr_resolve

Status: fixed on 2020/09/16 22:51
Subsystems: rdma
[Documentation on labels]
Reported-by: syzbot+08092148130652a6faae@syzkaller.appspotmail.com
Fix commit: f6a9d47ae685 RDMA/cma: Execute rdma_cm destruction from a handler properly
First crash: 1418d, last: 1418d
Discussions (3)
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) 1 (1) 2020/06/27 00:45
KASAN: use-after-free Write in addr_resolve 0 (1) 2020/06/10 17:03
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Write in addr_resolve (2) rdma 1 1160d 1156d 0/26 auto-closed as invalid on 2021/06/21 07:23

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in addr6_resolve drivers/infiniband/core/addr.c:437 [inline]
BUG: KASAN: use-after-free in addr_resolve+0x1871/0x1b80 drivers/infiniband/core/addr.c:588
Write of size 4 at addr ffff8880938d31a4 by task kworker/u4:0/7

CPU: 1 PID: 7 Comm: kworker/u4:0 Not tainted 5.7.0-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+0x1e9/0x30e lib/dump_stack.c:118
 print_address_description+0x66/0x5a0 mm/kasan/report.c:383
 __kasan_report mm/kasan/report.c:513 [inline]
 kasan_report+0x132/0x1d0 mm/kasan/report.c:530
 addr6_resolve drivers/infiniband/core/addr.c:437 [inline]
 addr_resolve+0x1871/0x1b80 drivers/infiniband/core/addr.c:588
 process_one_req+0xfb/0x570 drivers/infiniband/core/addr.c:628
 process_one_work+0x76e/0xfd0 kernel/workqueue.c:2268
 worker_thread+0xa7f/0x1450 kernel/workqueue.c:2414
 kthread+0x353/0x380 kernel/kthread.c:268
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:351

Allocated by task 3840:
 save_stack mm/kasan/common.c:48 [inline]
 set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc+0x103/0x140 mm/kasan/common.c:494
 kmem_cache_alloc_trace+0x234/0x300 mm/slab.c:3551
 kmalloc include/linux/slab.h:555 [inline]
 kzalloc include/linux/slab.h:669 [inline]
 __rdma_create_id+0x63/0x4f0 drivers/infiniband/core/cma.c:861
 ucma_create_id+0x259/0x540 drivers/infiniband/core/ucma.c:503
 ucma_write+0x2d3/0x350 drivers/infiniband/core/ucma.c:1729
 __vfs_write+0x9c/0x6e0 fs/read_write.c:495
 vfs_write+0x274/0x580 fs/read_write.c:559
 ksys_write+0x11b/0x220 fs/read_write.c:612
 do_syscall_64+0xf3/0x1b0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3

Freed by task 3832:
 save_stack mm/kasan/common.c:48 [inline]
 set_track mm/kasan/common.c:56 [inline]
 kasan_set_free_info mm/kasan/common.c:316 [inline]
 __kasan_slab_free+0x114/0x170 mm/kasan/common.c:455
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x10a/0x220 mm/slab.c:3757
 ucma_close+0x228/0x310 drivers/infiniband/core/ucma.c:1807
 __fput+0x2ed/0x750 fs/file_table.c:281
 task_work_run+0x147/0x1d0 kernel/task_work.c:123
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop arch/x86/entry/common.c:165 [inline]
 prepare_exit_to_usermode+0x48e/0x600 arch/x86/entry/common.c:196
 entry_SYSCALL_64_after_hwframe+0x49/0xb3

The buggy address belongs to the object at ffff8880938d3000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 420 bytes inside of
 2048-byte region [ffff8880938d3000, ffff8880938d3800)
The buggy address belongs to the page:
page:ffffea00024e34c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea00024f7188 ffffea00029aed48 ffff8880aa400e00
raw: 0000000000000000 ffff8880938d3000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880938d3080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880938d3100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880938d3180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff8880938d3200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880938d3280: 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
2020/06/07 17:29 upstream 7ae77150d94d 2c2b926c .config console log report ci-upstream-kasan-gce-smack-root
* Struck through repros no longer work on HEAD.