KASAN: use-after-free Read in userfaultfd_release

18 views
Skip to first unread message

syzbot

unread,
Nov 1, 2017, 2:04:09 PM11/1/17
to syzkaller-upst...@googlegroups.com
Hello,

syzkaller hit the following crash on
bb70832dd42b298d4303fd054bf18a78650ff04a
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/master
compiler: gcc (GCC) 7.1.1 20170620
.config is attached
Raw console output is attached.

syzkaller reproducer is attached. See https://goo.gl/kgGztJ
for information about syzkaller reproducers
CC: [linux-...@vger.kernel.org linux-...@vger.kernel.org
vi...@zeniv.linux.org.uk]

BUG: KASAN: use-after-free in userfaultfd_release+0x5c1/0x6e0
fs/userfaultfd.c:806
Read of size 8 at addr ffff8801c7830a20 by task syz-executor2/5515

CPU: 1 PID: 5515 Comm: syz-executor2 Not tainted 4.13.0-rc5-next-20170817+
#5
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:16 [inline]
dump_stack+0x194/0x257 lib/dump_stack.c:52
print_address_description+0x73/0x250 mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report+0x24e/0x340 mm/kasan/report.c:409
__asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430
userfaultfd_release+0x5c1/0x6e0 fs/userfaultfd.c:806
__fput+0x327/0x7e0 fs/file_table.c:210
____fput+0x15/0x20 fs/file_table.c:246
task_work_run+0x199/0x270 kernel/task_work.c:112
exit_task_work include/linux/task_work.h:21 [inline]
do_exit+0xa52/0x1b30 kernel/exit.c:865
do_group_exit+0x149/0x400 kernel/exit.c:968
get_signal+0x7e8/0x17e0 kernel/signal.c:2330
do_signal+0x94/0x1ee0 arch/x86/kernel/signal.c:808
exit_to_usermode_loop+0x224/0x300 arch/x86/entry/common.c:158
prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
syscall_return_slowpath+0x42f/0x500 arch/x86/entry/common.c:266
entry_SYSCALL_64_fastpath+0xbc/0xbe
RIP: 0033:0x4512e9
RSP: 002b:00007f36a3362c08 EFLAGS: 00000216 ORIG_RAX: 0000000000000013
RAX: 0000000000000020 RBX: 0000000000718150 RCX: 00000000004512e9
RDX: 0000000000000007 RSI: 0000000020053f90 RDI: 0000000000000007
RBP: 0000000000004420 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000216 R12: 00000000004b9b23
R13: 00000000ffffffff R14: 0000000000000007 R15: 0000000020053f90

Allocated by task 5495:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
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:551
kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489
kmem_cache_alloc+0x12e/0x760 mm/slab.c:3561
dup_userfaultfd+0x21c/0x890 fs/userfaultfd.c:635
dup_mmap kernel/fork.c:657 [inline]
dup_mm kernel/fork.c:1178 [inline]
copy_mm+0xa27/0x1247 kernel/fork.c:1232
copy_process.part.36+0x1ea3/0x4af0 kernel/fork.c:1734
copy_process kernel/fork.c:1547 [inline]
_do_fork+0x1ef/0xfb0 kernel/fork.c:2026
SYSC_clone kernel/fork.c:2136 [inline]
SyS_clone+0x37/0x50 kernel/fork.c:2130
do_syscall_64+0x26c/0x8c0 arch/x86/entry/common.c:287
return_from_SYSCALL_64+0x0/0x7a

Freed by task 5495:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
save_stack+0x43/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3503 [inline]
kmem_cache_free+0x77/0x280 mm/slab.c:3763
userfaultfd_ctx_put+0x50c/0x740 fs/userfaultfd.c:165
userfaultfd_event_wait_completion+0x754/0x910 fs/userfaultfd.c:581
dup_fctx fs/userfaultfd.c:669 [inline]
dup_userfaultfd_complete+0x2de/0x480 fs/userfaultfd.c:677
dup_mmap kernel/fork.c:719 [inline]
dup_mm kernel/fork.c:1178 [inline]
copy_mm+0xde2/0x1247 kernel/fork.c:1232
copy_process.part.36+0x1ea3/0x4af0 kernel/fork.c:1734
copy_process kernel/fork.c:1547 [inline]
_do_fork+0x1ef/0xfb0 kernel/fork.c:2026
SYSC_clone kernel/fork.c:2136 [inline]
SyS_clone+0x37/0x50 kernel/fork.c:2130
do_syscall_64+0x26c/0x8c0 arch/x86/entry/common.c:287
return_from_SYSCALL_64+0x0/0x7a

The buggy address belongs to the object at ffff8801c78308c0
which belongs to the cache userfaultfd_ctx_cache of size 360
The buggy address is located 352 bytes inside of
360-byte region [ffff8801c78308c0, ffff8801c7830a28)
The buggy address belongs to the page:
page:ffffea00071e0c00 count:1 mapcount:0 mapping:ffff8801c7830000
index:0xffff8801c7830ff7
flags: 0x200000000000100(slab)
raw: 0200000000000100 ffff8801c7830000 ffff8801c7830ff7 0000000100000009
raw: ffffea00071e9ba0 ffffea0007218c20 ffff8801d6515780 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801c7830900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801c7830980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff8801c7830a00: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc
^
ffff8801c7830a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff8801c7830b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================


---
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.
Please credit me with: Reported-by: syzbot <syzk...@googlegroups.com>

syzbot will keep track of this bug report.
Once a fix for this bug is committed, please reply to this email with:
#syz fix: exact-commit-title
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.
To upstream this report, please reply with:
#syz upstream
config.txt
raw.log
repro.txt

Dmitry Vyukov

unread,
Nov 1, 2017, 4:39:01 PM11/1/17
to syzbot, 'Dmitry Vyukov' via syzkaller-upstream-moderation
seems to be fixed by something, repro does not work anymore

#syz invalid

On Wed, Nov 1, 2017 at 9:04 PM, syzbot
<bot+d2f7ecbf393cacbf28...@syzkaller.appspotmail.com>
wrote:
> --
> You received this message because you are subscribed to the Google Groups
> "syzkaller-upstream-moderation" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to syzkaller-upstream-m...@googlegroups.com.
> To post to this group, send email to
> syzkaller-upst...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/syzkaller-upstream-moderation/001a113537f0ab9f07055cefb248%40google.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages