syzbot


WARNING: lock held when returning to user space in grab_super

Status: fixed on 2019/03/28 12:00
Subsystems: kernfs
[Documentation on labels]
Reported-by: syzbot+87b93137e0280beaeba1@syzkaller.appspotmail.com
Fix commit: 399504e21a10 fix cgroup_do_mount() handling of failure exits
First crash: 1993d, last: 1947d
Discussions (1)
Title Replies (including bot) Last reply
WARNING: lock held when returning to user space in grab_super 4 (5) 2019/01/02 16:55

Sample crash report:
R13: 00000000004c3bf8 R14: 00000000004d6d60 R15: 0000000000000003
================================================
WARNING: lock held when returning to user space!
5.0.0-rc6+ #70 Not tainted
------------------------------------------------
syz-executor.5/20707 is leaving the kernel with locks still held!
1 lock held by syz-executor.5/20707:
 #0: 00000000cd37815f (&type->s_umount_key#43){++++}, at: grab_super+0xaf/0x2c0 fs/super.c:384
kobject: 'loop3' (00000000779e4a1e): kobject_uevent_env
UDF-fs: error (device loop1): udf_read_tagged: read failed, block=256, location=256
UDF-fs: error (device loop1): udf_read_tagged: read failed, block=512, location=512
UDF-fs: warning (device loop1): udf_load_vrs: No anchor found
kobject: 'loop3' (00000000779e4a1e): fill_kobj_path: path = '/devices/virtual/block/loop3'
UDF-fs: Scanning with blocksize 512 failed
UDF-fs: error (device loop1): udf_read_tagged: read failed, block=256, location=256
UDF-fs: error (device loop1): udf_read_tagged: read failed, block=512, location=512
kobject: 'loop3' (00000000779e4a1e): kobject_uevent_env
UDF-fs: warning (device loop1): udf_load_vrs: No anchor found
UDF-fs: Scanning with blocksize 1024 failed
UDF-fs: error (device loop1): udf_read_tagged: read failed, block=256, location=256
kobject: 'loop3' (00000000779e4a1e): fill_kobj_path: path = '/devices/virtual/block/loop3'
UDF-fs: error (device loop1): udf_read_tagged: read failed, block=512, location=512
kobject: 'loop5' (00000000cbfdd486): kobject_uevent_env
UDF-fs: warning (device loop1): udf_load_vrs: No anchor found
kobject: 'loop5' (00000000cbfdd486): fill_kobj_path: path = '/devices/virtual/block/loop5'
UDF-fs: Scanning with blocksize 2048 failed
UDF-fs: error (device loop1): udf_read_tagged: read failed, block=256, location=256
kobject: 'loop3' (00000000779e4a1e): kobject_uevent_env
UDF-fs: error (device loop1): udf_read_tagged: read failed, block=512, location=512
kobject: 'loop3' (00000000779e4a1e): fill_kobj_path: path = '/devices/virtual/block/loop3'
UDF-fs: warning (device loop1): udf_load_vrs: No anchor found
UDF-fs: Scanning with blocksize 4096 failed
UDF-fs: warning (device loop1): udf_fill_super: No partition found (1)
kobject: 'loop3' (00000000779e4a1e): kobject_uevent_env
kobject: 'loop3' (00000000779e4a1e): fill_kobj_path: path = '/devices/virtual/block/loop3'
kobject: 'loop3' (00000000779e4a1e): kobject_uevent_env
kobject: 'loop3' (00000000779e4a1e): fill_kobj_path: path = '/devices/virtual/block/loop3'
kobject: 'loop1' (000000007a409a2a): kobject_uevent_env
kobject: 'loop1' (000000007a409a2a): fill_kobj_path: path = '/devices/virtual/block/loop1'
kobject: 'loop3' (00000000779e4a1e): kobject_uevent_env
kobject: 'loop3' (00000000779e4a1e): fill_kobj_path: path = '/devices/virtual/block/loop3'
==================================================================
BUG: KASAN: use-after-free in owner_on_cpu kernel/locking/rwsem-xadd.c:374 [inline]
BUG: KASAN: use-after-free in rwsem_can_spin_on_owner kernel/locking/rwsem-xadd.c:391 [inline]
BUG: KASAN: use-after-free in rwsem_optimistic_spin kernel/locking/rwsem-xadd.c:444 [inline]
BUG: KASAN: use-after-free in __rwsem_down_write_failed_common kernel/locking/rwsem-xadd.c:525 [inline]
BUG: KASAN: use-after-free in rwsem_down_write_failed+0xa8a/0xc30 kernel/locking/rwsem-xadd.c:613
Read of size 4 at addr ffff888086a903f8 by task syz-executor.0/20759

CPU: 1 PID: 20759 Comm: syz-executor.0 Not tainted 5.0.0-rc6+ #70
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.cold+0x7c/0x20d mm/kasan/report.c:187
 kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/generic_report.c:134
 owner_on_cpu kernel/locking/rwsem-xadd.c:374 [inline]
 rwsem_can_spin_on_owner kernel/locking/rwsem-xadd.c:391 [inline]
 rwsem_optimistic_spin kernel/locking/rwsem-xadd.c:444 [inline]
 __rwsem_down_write_failed_common kernel/locking/rwsem-xadd.c:525 [inline]
 rwsem_down_write_failed+0xa8a/0xc30 kernel/locking/rwsem-xadd.c:613
 call_rwsem_down_write_failed+0x17/0x30 arch/x86/lib/rwsem.S:117
 __down_write arch/x86/include/asm/rwsem.h:142 [inline]
 down_write+0x53/0x90 kernel/locking/rwsem.c:72
 grab_super+0xaf/0x2c0 fs/super.c:384
 sget_userns+0x35a/0xd30 fs/super.c:512
 kernfs_mount_ns+0x12a/0x880 fs/kernfs/mount.c:324
 kernfs_mount include/linux/kernfs.h:554 [inline]
 cgroup_do_mount+0xbb/0x300 kernel/cgroup/cgroup.c:2038
 cgroup_mount+0x976/0xac0 kernel/cgroup/cgroup.c:2102
 mount_fs+0x106/0x3ff fs/super.c:1258
 vfs_kern_mount.part.0+0x6f/0x410 fs/namespace.c:959
 vfs_kern_mount fs/namespace.c:949 [inline]
 do_new_mount fs/namespace.c:2513 [inline]
 do_mount+0x581/0x2d30 fs/namespace.c:2847
 ksys_mount+0xdb/0x150 fs/namespace.c:3063
 __do_sys_mount fs/namespace.c:3077 [inline]
 __se_sys_mount fs/namespace.c:3074 [inline]
 __x64_sys_mount+0xbe/0x150 fs/namespace.c:3074
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x457e29
Code: ad b8 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 7b b8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f3d07663c78 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 0000000000457e29
RDX: 0000000020000040 RSI: 0000000020000080 RDI: 0000000000000000
RBP: 000000000073c040 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f3d076646d4
R13: 00000000004c3bf8 R14: 00000000004d6d60 R15: 00000000ffffffff

Allocated by task 20696:
 save_stack+0x45/0xd0 mm/kasan/common.c:73
 set_track mm/kasan/common.c:85 [inline]
 __kasan_kmalloc mm/kasan/common.c:496 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:469
 kasan_kmalloc mm/kasan/common.c:504 [inline]
 kasan_slab_alloc+0xf/0x20 mm/kasan/common.c:411
 kmem_cache_alloc_node+0x144/0x710 mm/slab.c:3633
 alloc_task_struct_node kernel/fork.c:158 [inline]
 dup_task_struct kernel/fork.c:845 [inline]
 copy_process.part.0+0x1d08/0x79a0 kernel/fork.c:1753
 copy_process kernel/fork.c:1710 [inline]
 _do_fork+0x257/0xfe0 kernel/fork.c:2227
 __do_sys_clone kernel/fork.c:2334 [inline]
 __se_sys_clone kernel/fork.c:2328 [inline]
 __x64_sys_clone+0xbf/0x150 kernel/fork.c:2328
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 20738:
 save_stack+0x45/0xd0 mm/kasan/common.c:73
 set_track mm/kasan/common.c:85 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:458
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:466
 __cache_free mm/slab.c:3487 [inline]
 kmem_cache_free+0x86/0x260 mm/slab.c:3749
 free_task_struct kernel/fork.c:163 [inline]
 free_task+0xdd/0x120 kernel/fork.c:458
 __put_task_struct+0x20a/0x4e0 kernel/fork.c:731
 put_task_struct include/linux/sched/task.h:98 [inline]
 delayed_put_task_struct+0x1fd/0x350 kernel/exit.c:181
 __rcu_reclaim kernel/rcu/rcu.h:240 [inline]
 rcu_do_batch kernel/rcu/tree.c:2452 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:2773 [inline]
 rcu_process_callbacks+0x928/0x1390 kernel/rcu/tree.c:2754
 __do_softirq+0x266/0x95a kernel/softirq.c:292

The buggy address belongs to the object at ffff888086a903c0
 which belongs to the cache task_struct(97:syz5) of size 6080
The buggy address is located 56 bytes inside of
 6080-byte region [ffff888086a903c0, ffff888086a91b80)
The buggy address belongs to the page:
page:ffffea00021aa400 count:1 mapcount:0 mapping:ffff88808f59a900 index:0x0 compound_mapcount: 0
flags: 0x1fffc0000010200(slab|head)
raw: 01fffc0000010200 ffffea00022d8708 ffff88809f554048 ffff88808f59a900
raw: 0000000000000000 ffff888086a903c0 0000000100000001 ffff888096ca8b40
page dumped because: kasan: bad access detected
page->mem_cgroup:ffff888096ca8b40

Memory state around the buggy address:
 ffff888086a90280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888086a90300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888086a90380: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                                                ^
 ffff888086a90400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888086a90480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/02/14 10:55 upstream 1f947a7a011f 6a46f448 .config console log report ci-upstream-kasan-gce-smack-root
2018/12/30 09:55 upstream 195303136f19 35e3f847 .config console log report ci-upstream-kasan-gce
* Struck through repros no longer work on HEAD.