KASAN: use-after-free Read in ucma_close

20 views
Skip to first unread message

syzbot

unread,
Mar 7, 2018, 1:59:04 AM3/7/18
to dasaratharama...@intel.com, dled...@redhat.com, don....@intel.com, j...@ziepe.ca, le...@kernel.org, linux-...@vger.kernel.org, linux...@vger.kernel.org, pa...@mellanox.com, syzkall...@googlegroups.com, vi...@zeniv.linux.org.uk
Hello,

syzbot hit the following crash on upstream commit
ce380619fab99036f5e745c7a865b21c59f005f6 (Tue Mar 6 04:31:14 2018 +0000)
Merge tag 'please-pull-ia64_misc' of
git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux

So far this crash happened 6 times on upstream.
C reproducer is attached.
syzkaller reproducer is attached.
Raw console output is attached.
compiler: gcc (GCC) 7.1.1 20170620
.config is attached.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+dcfd34...@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed. See footer for
details.
If you forward the report, please keep this part and the footer.

audit: type=1400 audit(1520366586.501:7): avc: denied { map } for
pid=4239 comm="syzkaller296139" path="/root/syzkaller296139392" dev="sda1"
ino=16481 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
==================================================================
audit: type=1400 audit(1520366586.511:8): avc: denied { map } for
pid=4239 comm="syzkaller296139" path=2F6D656D66643A49202864656C6574656429
dev="tmpfs" ino=13679
scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=unconfined_u:object_r:tmpfs_t:s0 tclass=file permissive=1
BUG: KASAN: use-after-free in ucma_close+0x2d7/0x2f0
drivers/infiniband/core/ucma.c:1687
Read of size 8 at addr ffff8801af1739c0 by task syzkaller296139/4243

CPU: 1 PID: 4243 Comm: syzkaller296139 Not tainted 4.16.0-rc4+ #343
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
ucma_close+0x2d7/0x2f0 drivers/infiniband/core/ucma.c:1687
__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:0x445619
RSP: 002b:00007f603ee58da8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: 0000000000000001 RBX: 00000000006dac3c RCX: 0000000000445619
RDX: 0000000000445619 RSI: 0000000000000001 RDI: 00000000006dac3c
RBP: 00000000006dac38 R08: 0000000000000000 R09: 0000000000000000
R10: 00007f603ee59700 R11: 0000000000000246 R12: 006d635f616d6472
R13: 2f646e6162696e69 R14: 666e692f7665642f R15: 0000000000000004

Allocated by task 4240:
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]
ucma_alloc_ctx+0xce/0x610 drivers/infiniband/core/ucma.c:188
ucma_create_id+0x205/0x620 drivers/infiniband/core/ucma.c:473
ucma_write+0x2d6/0x3d0 drivers/infiniband/core/ucma.c:1627
__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 4240:
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
ucma_create_id+0x45b/0x620 drivers/infiniband/core/ucma.c:500
ucma_write+0x2d6/0x3d0 drivers/infiniband/core/ucma.c:1627
__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

The buggy address belongs to the object at ffff8801af173940
which belongs to the cache kmalloc-256 of size 256
The buggy address is located 128 bytes inside of
256-byte region [ffff8801af173940, ffff8801af173a40)
The buggy address belongs to the page:
page:ffffea0006bc5cc0 count:1 mapcount:0 mapping:ffff8801af173080 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffff8801af173080 0000000000000000 000000010000000c
raw: ffffea0006bda620 ffff8801dac01648 ffff8801dac007c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801af173880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801af173900: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
> ffff8801af173980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8801af173a00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff8801af173a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to syzk...@googlegroups.com.

syzbot will keep track of this bug report.
If you forgot to add the Reported-by tag, once the fix for this bug is
merged
into any tree, please reply to this email with:
#syz fix: exact-commit-title
If you want to test a patch for this bug, please reply with:
#syz test: git://repo/address.git branch
and provide the patch inline or as an attachment.
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug
report.
Note: all commands must start from beginning of the line in the email body.
raw.log.txt
repro.syz.txt
repro.c.txt
config.txt
Reply all
Reply to author
Forward
0 new messages