syzbot


WARNING: bad usercopy in fanotify_read

Status: fixed on 2019/04/01 10:28
Subsystems: hardening mm
[Documentation on labels]
Reported-by: syzbot+2c49971e251e36216d1f@syzkaller.appspotmail.com
Fix commit: b2d22b6bb33a fanotify: Allow copying of file handle to userspace
First crash: 1864d, last: 1864d
Cause bisection: introduced by (bisect log) :
commit a8b13aa20afb69161b5123b4f1acc7ea0a03d360
Author: Amir Goldstein <amir73il@gmail.com>
Date: Thu Jan 10 17:04:36 2019 +0000

  fanotify: enable FAN_REPORT_FID init flag

Crash: WARNING: bad usercopy in fanotify_read (log)
Repro: C syz .config
  
Discussions (2)
Title Replies (including bot) Last reply
WARNING: bad usercopy in fanotify_read 7 (9) 2019/03/19 08:32
Re: Fw: WARNING: bad usercopy in fanotify_read 3 (3) 2019/03/12 16:35

Sample crash report:
------------[ cut here ]------------
Bad or missing usercopy whitelist? Kernel memory exposure attempt detected from SLAB object 'fanotify_event' (offset 40, size 8)!
WARNING: CPU: 0 PID: 7968 at mm/usercopy.c:78 usercopy_warn+0xeb/0x110 mm/usercopy.c:78
Kernel panic - not syncing: panic_on_warn set ...
CPU: 0 PID: 7968 Comm: syz-executor245 Not tainted 5.0.0+ #18
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+0x172/0x1f0 lib/dump_stack.c:113
 panic+0x2cb/0x65c kernel/panic.c:214
 __warn.cold+0x20/0x45 kernel/panic.c:571
 report_bug+0x263/0x2b0 lib/bug.c:186
 fixup_bug arch/x86/kernel/traps.c:179 [inline]
 fixup_bug arch/x86/kernel/traps.c:174 [inline]
 do_error_trap+0x11b/0x200 arch/x86/kernel/traps.c:272
 do_invalid_op+0x37/0x50 arch/x86/kernel/traps.c:291
 invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:973
RIP: 0010:usercopy_warn+0xeb/0x110 mm/usercopy.c:78
Code: c8 e8 39 89 c0 ff 4c 8b 45 c0 4d 89 e9 4c 89 e1 48 8b 55 c8 41 57 48 89 de 48 c7 c7 a0 dc 74 87 ff 75 d0 41 56 e8 63 4b 93 ff <0f> 0b 48 83 c4 18 e9 46 ff ff ff 49 c7 c5 a0 da 74 87 4d 89 ee 4d
RSP: 0018:ffff88808805fb18 EFLAGS: 00010282
RAX: 0000000000000000 RBX: ffffffff8774dc60 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff815ad7b6 RDI: ffffed101100bf55
RBP: ffff88808805fb70 R08: ffff8880a90d4400 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff8859448d
R13: ffffffff8775d4c0 R14: ffffffff8774dae0 R15: 0000000000000008
 __check_heap_object+0x88/0xb3 mm/slab.c:4453
 check_heap_object mm/usercopy.c:238 [inline]
 __check_object_size mm/usercopy.c:284 [inline]
 __check_object_size+0x342/0x42f mm/usercopy.c:254
 check_object_size include/linux/thread_info.h:119 [inline]
 check_copy_size include/linux/thread_info.h:150 [inline]
 copy_to_user include/linux/uaccess.h:151 [inline]
 copy_fid_to_user fs/notify/fanotify/fanotify_user.c:236 [inline]
 copy_event_to_user fs/notify/fanotify/fanotify_user.c:294 [inline]
 fanotify_read+0xde0/0x1430 fs/notify/fanotify/fanotify_user.c:362
 __vfs_read+0x8d/0x110 fs/read_write.c:416
 vfs_read+0x194/0x3e0 fs/read_write.c:452
 ksys_read+0xea/0x1f0 fs/read_write.c:578
 __do_sys_read fs/read_write.c:588 [inline]
 __se_sys_read fs/read_write.c:586 [inline]
 __x64_sys_read+0x73/0xb0 fs/read_write.c:586
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4456b9
Code: e8 6c b6 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 2b 12 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f254fba2db8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00000000006dac28 RCX: 00000000004456b9
RDX: 000000000000006b RSI: 0000000020000000 RDI: 0000000000000004
RBP: 00000000006dac20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dac2c
R13: 00007ffe4bf739ff R14: 00007f254fba39c0 R15: 20c49ba5e353f7cf
Kernel Offset: disabled
Rebooting in 86400 seconds..

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/03/12 01:18 upstream a089e4fed5c5 12365b99 .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/03/11 19:16 upstream 12ad143e1b80 12365b99 .config console log report syz C ci-upstream-kasan-gce-root
2019/03/11 18:59 upstream 12ad143e1b80 12365b99 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/03/12 10:38 linux-next cf08baa29613 12365b99 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/03/11 18:39 upstream 12ad143e1b80 12365b99 .config console log report ci-upstream-kasan-gce-selinux-root
* Struck through repros no longer work on HEAD.