syzbot


KASAN: use-after-free Read in __list_del_entry_valid (4)

Status: fixed on 2020/05/10 10:41
Reported-by: syzbot+29ee8f76017ce6cf03da@syzkaller.appspotmail.com
Fix commit: 7c11910783a1 RDMA/ucma: Put a lock around every call to the rdma_cm layer
First crash: 1721d, last: 1032d

Cause bisection: the issue happens on the oldest tested release (bisect log)
Crash: WARNING in cma_cancel_operation (log)
Repro: C syz .config
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in __list_del_entry_valid (3) C 15 1726d 1740d 24/24 closed as dup on 2018/03/22 15:31
upstream KASAN: use-after-free Read in __list_del_entry_valid (2) C 11 1816d 1818d 3/24 fixed on 2018/01/11 01:23

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __list_del_entry_valid+0x144/0x150 lib/list_debug.c:54
Read of size 8 at addr ffff8801b94cef60 by task syzkaller058671/4231

CPU: 0 PID: 4231 Comm: syzkaller058671 Not tainted 4.16.0-rc6+ #366
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+0x194/0x24d lib/dump_stack.c:53
 print_address_description+0x73/0x250 mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report+0x23c/0x360 mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 __list_del_entry_valid+0x144/0x150 lib/list_debug.c:54
 __list_del_entry include/linux/list.h:117 [inline]
 list_del include/linux/list.h:125 [inline]
 cma_cancel_listens drivers/infiniband/core/cma.c:1569 [inline]
 cma_cancel_operation+0x455/0xd60 drivers/infiniband/core/cma.c:1597
 rdma_destroy_id+0xff/0xda0 drivers/infiniband/core/cma.c:1661
 ucma_close+0x100/0x2f0 drivers/infiniband/core/ucma.c:1728
 __fput+0x327/0x7e0 fs/file_table.c:209
 ____fput+0x15/0x20 fs/file_table.c:243
 task_work_run+0x199/0x270 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x9bb/0x1ad0 kernel/exit.c:865
 do_group_exit+0x149/0x400 kernel/exit.c:968
 get_signal+0x73a/0x16d0 kernel/signal.c:2469
 do_signal+0x90/0x1e90 arch/x86/kernel/signal.c:809
 exit_to_usermode_loop+0x258/0x2f0 arch/x86/entry/common.c:162
 prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:265 [inline]
 do_syscall_64+0x6ec/0x940 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x446a49
RSP: 002b:00007fb425dffda8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: fffffffffffffe00 RBX: 00000000006e29fc RCX: 0000000000446a49
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000006e29fc
RBP: 00000000006e29f8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 006d635f616d6472
R13: 2f646e6162696e69 R14: 666e692f7665642f R15: 0000000000000005

Allocated by task 4228:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:552
 kmem_cache_alloc_trace+0x136/0x740 mm/slab.c:3607
 kmalloc include/linux/slab.h:512 [inline]
 kzalloc include/linux/slab.h:701 [inline]
 rdma_create_id+0xd0/0x630 drivers/infiniband/core/cma.c:787
 ucma_create_id+0x35f/0x920 drivers/infiniband/core/ucma.c:480
 ucma_write+0x2d6/0x3d0 drivers/infiniband/core/ucma.c:1649
 __vfs_write+0xef/0x970 fs/read_write.c:480
 vfs_write+0x189/0x510 fs/read_write.c:544
 SYSC_write fs/read_write.c:589 [inline]
 SyS_write+0xef/0x220 fs/read_write.c:581
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 4231:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:520
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:527
 __cache_free mm/slab.c:3485 [inline]
 kfree+0xd9/0x260 mm/slab.c:3800
 rdma_destroy_id+0x821/0xda0 drivers/infiniband/core/cma.c:1691
 ucma_close+0x100/0x2f0 drivers/infiniband/core/ucma.c:1728
 __fput+0x327/0x7e0 fs/file_table.c:209
 ____fput+0x15/0x20 fs/file_table.c:243
 task_work_run+0x199/0x270 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x9bb/0x1ad0 kernel/exit.c:865
 do_group_exit+0x149/0x400 kernel/exit.c:968
 get_signal+0x73a/0x16d0 kernel/signal.c:2469
 do_signal+0x90/0x1e90 arch/x86/kernel/signal.c:809
 exit_to_usermode_loop+0x258/0x2f0 arch/x86/entry/common.c:162
 prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:265 [inline]
 do_syscall_64+0x6ec/0x940 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff8801b94ced80
 which belongs to the cache kmalloc-1024 of size 1024
The buggy address is located 480 bytes inside of
 1024-byte region [ffff8801b94ced80, ffff8801b94cf180)
The buggy address belongs to the page:
page:ffffea0006e53380 count:1 mapcount:0 mapping:ffff8801b94ce000 index:0x0 compound_mapcount: 0
flags: 0x2fffc0000008100(slab|head)
raw: 02fffc0000008100 ffff8801b94ce000 0000000000000000 0000000100000007
raw: ffffea0006e8ad20 ffff8801dac01848 ffff8801dac00ac0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801b94cee00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801b94cee80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8801b94cef00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                       ^
 ffff8801b94cef80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801b94cf000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Fix bisection attempts:
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce 2020/02/11 22:27 upstream 0a679e13ea30 e033c1f1 .config log report syz C
ci-upstream-kasan-gce 2020/01/12 22:04 upstream 040a3c33623b e033c1f1 .config log report syz C
ci-upstream-kasan-gce-root 2019/12/10 15:05 upstream 6794862a16ef e033c1f1 .config log report syz C
ci-upstream-kasan-gce-root 2019/08/01 03:15 upstream 3eb2ce825ea1 e033c1f1 .config log report syz C
* Struck through repros no longer work on HEAD.
Crashes (16):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce 2018/03/26 04:05 upstream cb6416592bc2 e033c1f1 .config log report syz C
ci-upstream-kasan-gce-root 2018/03/26 03:42 upstream 3eb2ce825ea1 e033c1f1 .config log report syz C
ci-upstream-kasan-gce-386 2018/03/26 03:55 upstream cb6416592bc2 e033c1f1 .config log report syz
ci-upstream-kasan-gce-386 2018/03/24 20:37 upstream bcfc1f455466 2e9d9054 .config log report syz
ci-upstream-kasan-gce-root 2018/03/27 04:28 upstream 3eb2ce825ea1 0ca7878b .config log report
ci-upstream-kasan-gce-root 2018/03/26 03:25 upstream 3eb2ce825ea1 e033c1f1 .config log report
ci-upstream-kasan-gce-386 2018/04/01 09:31 upstream 10b84daddbec 0174c6c8 .config log report
ci-upstream-kasan-gce-386 2018/04/01 07:09 upstream 10b84daddbec 0174c6c8 .config log report
ci-upstream-kasan-gce-386 2018/04/01 01:57 upstream 10b84daddbec 0174c6c8 .config log report
ci-upstream-kasan-gce-386 2018/03/31 12:29 upstream b5dbc28762fd 8fbce0e4 .config log report
ci-upstream-kasan-gce-386 2018/03/30 04:02 upstream 0b412605ef5f d47f0ed6 .config log report
ci-upstream-kasan-gce-386 2018/03/29 11:28 upstream 0b412605ef5f d47f0ed6 .config log report
ci-upstream-kasan-gce-386 2018/03/29 06:04 upstream a2601d78b77a bf5e585c .config log report
ci-upstream-kasan-gce-386 2018/03/29 05:50 upstream a2601d78b77a bf5e585c .config log report
ci-upstream-kasan-gce-386 2018/03/29 04:31 upstream a2601d78b77a bf5e585c .config log report
ci-upstream-kasan-gce-386 2018/03/24 20:18 upstream bcfc1f455466 2e9d9054 .config log report
* Struck through repros no longer work on HEAD.