syzbot


KASAN: use-after-free Read in do_mount

Status: fixed on 2019/11/29 15:48
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+da4f525235510683d855@syzkaller.appspotmail.com
Fix commit: 0ecee6699064 fs/namespace.c: fix use-after-free of mount in mnt_warn_timestamp_expiry()
First crash: 1834d, last: 1822d
Cause bisection: introduced by (bisect log) :
commit 9d14545b05f9eed69fbd4af14b927a462324ea19
Author: Arnd Bergmann <arnd@arndb.de>
Date: Fri Aug 30 16:12:15 2019 +0000

  Merge branch 'limits' of https://github.com/deepa-hub/vfs into y2038

Crash: KASAN: use-after-free Read in do_mount (log)
Repro: syz .config
  
Duplicate bugs (1)
duplicates (1):
Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
KASAN: use-after-free Read in mnt_warn_timestamp_expiry fs syz done 1 1821d 1821d 0/28 closed as dup on 2019/10/17 01:47
Discussions (3)
Title Replies (including bot) Last reply
[PATCH v2] fs/namespace.c: fix use-after-free of mount in mnt_warn_timestamp_expiry() 2 (2) 2019/10/17 03:15
[PATCH] fs/namespace.c: fix use-after-free of mount in mnt_warn_timestamp_expiry() 3 (3) 2019/10/14 03:22
KASAN: use-after-free Read in do_mount 0 (1) 2019/10/07 23:09

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in do_new_mount_fc fs/namespace.c:2773 [inline]
BUG: KASAN: use-after-free in do_new_mount fs/namespace.c:2825 [inline]
BUG: KASAN: use-after-free in do_mount+0x1b5f/0x1d10 fs/namespace.c:3143
Read of size 8 at addr ffff8880972929a8 by task syz-executor.1/6243

CPU: 0 PID: 6243 Comm: syz-executor.1 Not tainted 5.4.0-rc3+ #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+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
 __kasan_report.cold+0x1b/0x41 mm/kasan/report.c:506
 kasan_report+0x12/0x20 mm/kasan/common.c:634
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
 do_new_mount_fc fs/namespace.c:2773 [inline]
 do_new_mount fs/namespace.c:2825 [inline]
 do_mount+0x1b5f/0x1d10 fs/namespace.c:3143
 ksys_mount+0xdb/0x150 fs/namespace.c:3352
 __do_sys_mount fs/namespace.c:3366 [inline]
 __se_sys_mount fs/namespace.c:3363 [inline]
 __x64_sys_mount+0xbe/0x150 fs/namespace.c:3363
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x459a59
Code: fd b7 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 b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fea83ea6c78 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 0000000000459a59
RDX: 0000000020000a40 RSI: 00000000200005c0 RDI: 0000000000000000
RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fea83ea76d4
R13: 00000000004c6293 R14: 00000000004db2f8 R15: 00000000ffffffff

Allocated by task 6243:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 __kasan_kmalloc mm/kasan/common.c:510 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:483
 kasan_slab_alloc+0xf/0x20 mm/kasan/common.c:518
 slab_post_alloc_hook mm/slab.h:584 [inline]
 slab_alloc mm/slab.c:3319 [inline]
 kmem_cache_alloc+0x121/0x710 mm/slab.c:3483
 kmem_cache_zalloc include/linux/slab.h:680 [inline]
 alloc_vfsmnt+0x28/0x680 fs/namespace.c:177
 vfs_create_mount+0x96/0x500 fs/namespace.c:940
 do_new_mount_fc fs/namespace.c:2763 [inline]
 do_new_mount fs/namespace.c:2825 [inline]
 do_mount+0x17ae/0x1d10 fs/namespace.c:3143
 ksys_mount+0xdb/0x150 fs/namespace.c:3352
 __do_sys_mount fs/namespace.c:3366 [inline]
 __se_sys_mount fs/namespace.c:3363 [inline]
 __x64_sys_mount+0xbe/0x150 fs/namespace.c:3363
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 16:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 kasan_set_free_info mm/kasan/common.c:332 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:471
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:480
 __cache_free mm/slab.c:3425 [inline]
 kmem_cache_free+0x86/0x320 mm/slab.c:3693
 free_vfsmnt+0x6f/0x90 fs/namespace.c:554
 delayed_free_vfsmnt+0x16/0x20 fs/namespace.c:559
 __rcu_reclaim kernel/rcu/rcu.h:222 [inline]
 rcu_do_batch kernel/rcu/tree.c:2157 [inline]
 rcu_core+0x581/0x1560 kernel/rcu/tree.c:2377
 rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2386
 __do_softirq+0x262/0x98c kernel/softirq.c:292

The buggy address belongs to the object at ffff888097292980
 which belongs to the cache mnt_cache of size 312
The buggy address is located 40 bytes inside of
 312-byte region [ffff888097292980, ffff888097292ab8)
The buggy address belongs to the page:
page:ffffea00025ca480 refcount:1 mapcount:0 mapping:ffff8880aa5a88c0 index:0x0
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea0002a4d148 ffffea00020c4e48 ffff8880aa5a88c0
raw: 0000000000000000 ffff888097292080 000000010000000a 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888097292880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888097292900: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc
>ffff888097292980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                  ^
 ffff888097292a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888097292a80: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/10/15 22:21 upstream 5bc52f64e884 b5268b89 .config console log report syz ci-upstream-kasan-gce-root
2019/10/04 15:24 linux-next 311ef88adfa3 b2f369e5 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2019/10/03 21:48 upstream 0f1a7b3fac05 fc17ba49 .config console log report ci-upstream-kasan-gce-selinux-root
2019/10/10 10:43 linux-next 4a9e93dbc796 a4efa8c0 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/04 12:13 linux-next 311ef88adfa3 b2f369e5 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/10/03 19:47 linux-next 2521ffab5375 fc17ba49 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.