syzbot


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

Status: upstream: reported C repro on 2020/07/13 02:24
Reported-by: syzbot+75867c44841cb6373570@syzkaller.appspotmail.com
First crash: 811d, last: 802d

Cause bisection: introduced by (bisect log) :
commit d08ac70b1e0dc71ac2315007bcc3efb283b2eae4
Author: Daniel Colascione <dancol@google.com>
Date: Wed Apr 1 21:39:03 2020 +0000

  Wire UFFD up to SELinux

Crash: KASAN: use-after-free Read in userfaultfd_release (log)
Repro: C syz .config
similar bugs (1):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in userfaultfd_release syz 243 1820d 1792d 0/24 closed as invalid on 2017/11/01 20:39
Patch testing requests:
Created Duration User Patch Repo Result
2022/09/18 18:29 10m linux-next report log
2021/04/15 14:13 15m alaaemadhossney.ae@gmail.com linux-next OK

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in userfaultfd_release+0x57f/0x5f0 fs/userfaultfd.c:879
Read of size 8 at addr ffff88809b09af88 by task syz-executor902/6813

CPU: 0 PID: 6813 Comm: syz-executor902 Not tainted 5.8.0-rc4-next-20200708-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
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/0x497 mm/kasan/report.c:383
 __kasan_report mm/kasan/report.c:513 [inline]
 kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
 userfaultfd_release+0x57f/0x5f0 fs/userfaultfd.c:879
 __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
RIP: 0033:0x4401f9
Code: Bad RIP value.
RSP: 002b:00007ffdd722dfe8 EFLAGS: 00000246 ORIG_RAX: 0000000000000143
RAX: ffffffffffffffe8 RBX: 00000000004002c8 RCX: 00000000004401f9
RDX: 00000000004401f9 RSI: 0000000000400aa0 RDI: 0000000000000000
RBP: 00000000006ca018 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000401a00
R13: 0000000000401a90 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 6813:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:461
 slab_post_alloc_hook mm/slab.h:536 [inline]
 slab_alloc mm/slab.c:3312 [inline]
 kmem_cache_alloc+0x148/0x550 mm/slab.c:3482
 __do_sys_userfaultfd+0x96/0x4b0 fs/userfaultfd.c:2026
 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 6813:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:56
 kasan_set_free_info+0x1b/0x30 mm/kasan/generic.c:355
 __kasan_slab_free+0xd8/0x120 mm/kasan/common.c:422
 __cache_free mm/slab.c:3418 [inline]
 kmem_cache_free.part.0+0x67/0x1f0 mm/slab.c:3693
 __do_sys_userfaultfd+0x3cf/0x4b0 fs/userfaultfd.c:2061
 do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff88809b09ae00
 which belongs to the cache userfaultfd_ctx_cache of size 408
The buggy address is located 392 bytes inside of
 408-byte region [ffff88809b09ae00, ffff88809b09af98)
The buggy address belongs to the page:
page:ffffea00026c2680 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880a03d5dc0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffff8880a3de5d50 ffff8880a3de5d50 ffff888219701b00
raw: ffff8880a03d5dc0 ffff88809b09a000 0000000100000008 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809b09ae80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809b09af00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88809b09af80: fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc
                      ^
 ffff88809b09b000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809b09b080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (5):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-linux-next-kasan-gce-root 2020/07/09 11:20 linux-next 8903263671cb bc238812 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/07/18 11:12 linux-next 4c43049f19a2 9c812472 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/07/11 09:22 linux-next d31958b30ea3 18d18b59 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/07/09 08:30 linux-next 8903263671cb bc238812 .config log report
ci-upstream-linux-next-kasan-gce-root 2020/07/09 02:15 linux-next 8903263671cb bc238812 .config log report
* Struck through repros no longer work on HEAD.