syzbot


KASAN: use-after-free Read in link_path_walk

Status: fixed on 2019/04/12 08:05
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+fb731ca573367b7f6564@syzkaller.appspotmail.com
Fix commit: 1da6c4d9140c bpf: fix use after free in bpf_evict_inode
First crash: 2141d, last: 2126d
Cause bisection: introduced by (bisect log) :
commit 0f98621bef5d2b7ad41f6595899660af344f5016
Author: Daniel Borkmann <daniel@iogearbox.net>
Date: Sat Oct 29 00:30:46 2016 +0000

  bpf, inode: add support for symlinks and fix mtime/ctime

Crash: KASAN: use-after-free Read in trailing_symlink (log)
Repro: syz .config
  
Discussions (5)
Title Replies (including bot) Last reply
[PATCH 5.0 00/93] 5.0.9-stable review 116 (116) 2019/04/20 14:41
[PATCH 4.19 000/110] 4.19.36-stable review 119 (119) 2019/04/20 05:33
[PATCH 4.14 00/92] 4.14.113-stable review 100 (100) 2019/04/19 19:39
KASAN: use-after-free Read in path_lookupat 31 (33) 2019/04/10 19:44
KASAN: use-after-free Read in link_path_walk 0 (2) 2019/03/25 04:52
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-44 KASAN: use-after-free Read in link_path_walk 17 2257d 2453d 0/2 auto-closed as invalid on 2019/02/22 12:34
android-414 KASAN: use-after-free Read in link_path_walk syz 2 2063d 2006d 0/1 public: reported syz repro on 2019/04/13 00:01
android-49 KASAN: use-after-free Read in link_path_walk C 56 2258d 2007d 0/3 public: reported C repro on 2019/04/11 08:44
Last patch testing requests (1)
Created Duration User Patch Repo Result
2019/03/25 15:30 15m daniel@iogearbox.net git://git.kernel.org/pub/scm/linux/kernel/git/dborkman/bpf.git bpf-fs-fix OK

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in link_path_walk.part.40+0x12e6/0x1530 fs/namei.c:2091
Read of size 1 at addr ffff8881c2948b02 by task syz-executor2/15759

CPU: 0 PID: 15759 Comm: syz-executor2 Not tainted 4.20.0-rc6+ #151
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+0x244/0x39d lib/dump_stack.c:113
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load1_noabort+0x14/0x20 mm/kasan/report.c:430
 link_path_walk.part.40+0x12e6/0x1530 fs/namei.c:2091
 link_path_walk fs/namei.c:2269 [inline]
 path_lookupat.isra.43+0xf7/0xc00 fs/namei.c:2317
 filename_lookup+0x26a/0x520 fs/namei.c:2348
 user_path_at_empty+0x40/0x50 fs/namei.c:2608
 user_path include/linux/namei.h:62 [inline]
 do_mount+0x177/0x31f0 fs/namespace.c:2741
 ksys_mount+0x12d/0x140 fs/namespace.c:3017
 __do_sys_mount fs/namespace.c:3031 [inline]
 __se_sys_mount fs/namespace.c:3028 [inline]
 __x64_sys_mount+0xbe/0x150 fs/namespace.c:3028
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x457679
Code: fd b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 cb b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f265e69ac78 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 0000000000457679
RDX: 0000000020000040 RSI: 0000000020000000 RDI: 0000000000000000
RBP: 000000000072bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000200000 R11: 0000000000000246 R12: 00007f265e69b6d4
R13: 00000000004c2e25 R14: 00000000004d5200 R15: 00000000ffffffff

Allocated by task 15760:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 __do_kmalloc mm/slab.c:3722 [inline]
 __kmalloc_track_caller+0x157/0x760 mm/slab.c:3737
 kstrdup+0x39/0x70 mm/util.c:49
 bpf_symlink+0x26/0x140 kernel/bpf/inode.c:356
 vfs_symlink+0x37a/0x5d0 fs/namei.c:4127
 do_symlinkat+0x242/0x2d0 fs/namei.c:4154
 __do_sys_symlink fs/namei.c:4173 [inline]
 __se_sys_symlink fs/namei.c:4171 [inline]
 __x64_sys_symlink+0x59/0x80 fs/namei.c:4171
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 15766:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xcf/0x230 mm/slab.c:3817
 bpf_evict_inode+0x11f/0x150 kernel/bpf/inode.c:565
 evict+0x4b9/0x980 fs/inode.c:558
 iput_final fs/inode.c:1550 [inline]
 iput+0x679/0xa90 fs/inode.c:1576
 do_unlinkat+0x733/0xa30 fs/namei.c:4069
 __do_sys_unlink fs/namei.c:4110 [inline]
 __se_sys_unlink fs/namei.c:4108 [inline]
 __x64_sys_unlink+0x42/0x50 fs/namei.c:4108
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8881c2948b00
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 2 bytes inside of
 32-byte region [ffff8881c2948b00, ffff8881c2948b20)
The buggy address belongs to the page:
page:ffffea00070a5200 count:1 mapcount:0 mapping:ffff8881da8001c0 index:0xffff8881c2948fc1
flags: 0x2fffc0000000200(slab)
raw: 02fffc0000000200 ffffea0007614888 ffffea0006d6afc8 ffff8881da8001c0
raw: ffff8881c2948fc1 ffff8881c2948000 000000010000003e 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8881c2948a00: 00 07 fc fc fc fc fc fc fb fb fb fb fc fc fc fc
 ffff8881c2948a80: 00 00 00 fc fc fc fc fc fb fb fb fb fc fc fc fc
>ffff8881c2948b00: fb fb fb fb fc fc fc fc 00 00 00 fc fc fc fc fc
                   ^
 ffff8881c2948b80: fb fb fb fb fc fc fc fc 00 00 01 fc fc fc fc fc
 ffff8881c2948c00: 00 00 00 fc fc fc fc fc 00 00 00 fc fc fc fc fc
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/12/13 00:05 upstream f5d582777bcb 02613a41 .config console log report syz ci-upstream-kasan-gce-selinux-root
2018/11/28 09:10 upstream ef78e5ec9214 4b6d14f2 .config console log report syz ci-upstream-kasan-gce-selinux-root
2018/12/14 05:55 linux-next ca40dc225d19 fe7127be .config console log report syz ci-upstream-linux-next-kasan-gce-root
2018/12/12 22:16 upstream f5d582777bcb 02613a41 .config console log report ci-upstream-kasan-gce-selinux-root
2018/11/28 08:21 upstream ef78e5ec9214 4b6d14f2 .config console log report ci-upstream-kasan-gce-selinux-root
* Struck through repros no longer work on HEAD.