syzbot


KASAN: use-after-free Write in selinux_sb_copy_data

Status: public: reported C repro on 2019/04/13 00:00
Reported-by: syzbot+11d3010ed0f15a778525@syzkaller.appspotmail.com
First crash: 2423d, last: 2279d

Sample crash report:
random: sshd: uninitialized urandom read (32 bytes read)
random: sshd: uninitialized urandom read (32 bytes read)
random: sshd: uninitialized urandom read (32 bytes read)
random: sshd: uninitialized urandom read (32 bytes read)
==================================================================
BUG: KASAN: use-after-free in take_option security/selinux/hooks.c:2619 [inline]
BUG: KASAN: use-after-free in selinux_sb_copy_data+0x1cd/0x380 security/selinux/hooks.c:2674
Write of size 10 at addr ffff8801c3b7a000 by task syz-executor060/3805

CPU: 0 PID: 3805 Comm: syz-executor060 Not tainted 4.9.122-g54068d6 #26
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
 ffff8801b8a3f4c8 ffffffff81eb8829 ffffea00070ede80 ffff8801c3b7a000
 0000000000000001 ffff8801c3b7a000 000000000000000a ffff8801b8a3f500
 ffffffff8156b6be ffff8801c3b7a000 000000000000000a 0000000000000001
Call Trace:
 [<ffffffff81eb8829>] __dump_stack lib/dump_stack.c:15 [inline]
 [<ffffffff81eb8829>] dump_stack+0xc1/0x128 lib/dump_stack.c:51
 [<ffffffff8156b6be>] print_address_description+0x6c/0x234 mm/kasan/report.c:256
 [<ffffffff8156bac8>] kasan_report_error mm/kasan/report.c:355 [inline]
 [<ffffffff8156bac8>] kasan_report.cold.6+0x242/0x2fe mm/kasan/report.c:412
 [<ffffffff8153e16f>] check_memory_region_inline mm/kasan/kasan.c:318 [inline]
 [<ffffffff8153e16f>] check_memory_region+0x14f/0x1b0 mm/kasan/kasan.c:325
 [<ffffffff8153e7c7>] memcpy+0x37/0x50 mm/kasan/kasan.c:361
 [<ffffffff81d0d8ed>] take_option security/selinux/hooks.c:2619 [inline]
 [<ffffffff81d0d8ed>] selinux_sb_copy_data+0x1cd/0x380 security/selinux/hooks.c:2674
 [<ffffffff81cef45b>] security_sb_copy_data+0x7b/0xb0 security/security.c:283
 [<ffffffff8197fa86>] parse_security_options+0x36/0x90 fs/btrfs/super.c:1493
 [<ffffffff81990ab3>] btrfs_mount+0x2f3/0x2bc0 fs/btrfs/super.c:1572
 [<ffffffff81581d9c>] mount_fs+0x28c/0x370 fs/super.c:1206
 [<ffffffff815e1681>] vfs_kern_mount.part.29+0xd1/0x3d0 fs/namespace.c:1000
 [<ffffffff815e19c0>] vfs_kern_mount+0x40/0x60 fs/namespace.c:982
 [<ffffffff81990bcb>] mount_subvol fs/btrfs/super.c:1395 [inline]
 [<ffffffff81990bcb>] btrfs_mount+0x40b/0x2bc0 fs/btrfs/super.c:1566
 [<ffffffff81581d9c>] mount_fs+0x28c/0x370 fs/super.c:1206
 [<ffffffff815e1681>] vfs_kern_mount.part.29+0xd1/0x3d0 fs/namespace.c:1000
 [<ffffffff815e8ea9>] vfs_kern_mount fs/namespace.c:982 [inline]
 [<ffffffff815e8ea9>] do_new_mount fs/namespace.c:2537 [inline]
 [<ffffffff815e8ea9>] do_mount+0x3c9/0x2740 fs/namespace.c:2859
 [<ffffffff815ebbfe>] SYSC_mount fs/namespace.c:3075 [inline]
 [<ffffffff815ebbfe>] SyS_mount+0xfe/0x110 fs/namespace.c:3052
 [<ffffffff81006316>] do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
 [<ffffffff83a00cd3>] entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Allocated by task 2217:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack+0x43/0xd0 mm/kasan/kasan.c:505
 set_track mm/kasan/kasan.c:517 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:609
 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:547
 slab_post_alloc_hook mm/slab.h:417 [inline]
 slab_alloc_node mm/slub.c:2715 [inline]
 slab_alloc mm/slub.c:2723 [inline]
 kmem_cache_alloc+0xbe/0x290 mm/slub.c:2728
 kmem_cache_zalloc include/linux/slab.h:626 [inline]
 file_alloc_security security/selinux/hooks.c:365 [inline]
 selinux_file_alloc_security+0xae/0x190 security/selinux/hooks.c:3392
 security_file_alloc+0x73/0xb0 security/security.c:787
 get_empty_filp+0x11e/0x380 fs/file_table.c:128
 alloc_file+0x20/0x350 fs/file_table.c:163
 anon_inode_getfile+0x1a4/0x350 fs/anon_inodes.c:105
 anon_inode_getfd+0x45/0x90 fs/anon_inodes.c:150
 SYSC_signalfd4 fs/signalfd.c:285 [inline]
 SyS_signalfd4+0x237/0x430 fs/signalfd.c:255
 do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
 entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Freed by task 2217:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack+0x43/0xd0 mm/kasan/kasan.c:505
 set_track mm/kasan/kasan.c:517 [inline]
 kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:582
 slab_free_hook mm/slub.c:1355 [inline]
 slab_free_freelist_hook mm/slub.c:1377 [inline]
 slab_free mm/slub.c:2958 [inline]
 kmem_cache_free+0xbe/0x310 mm/slub.c:2980
 file_free_security security/selinux/hooks.c:380 [inline]
 selinux_file_free_security+0x49/0x60 security/selinux/hooks.c:3397
 security_file_free+0x4e/0x90 security/security.c:792
 __fput+0x270/0x700 fs/file_table.c:209
 ____fput+0x15/0x20 fs/file_table.c:244
 task_work_run+0x10c/0x180 kernel/task_work.c:116
 tracehook_notify_resume include/linux/tracehook.h:191 [inline]
 exit_to_usermode_loop+0xfc/0x120 arch/x86/entry/common.c:161
 prepare_exit_to_usermode arch/x86/entry/common.c:191 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:260 [inline]
 do_syscall_64+0x364/0x490 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_swapgs+0x5d/0xdb

The buggy address belongs to the object at ffff8801c3b7a000
 which belongs to the cache selinux_file_security of size 16
The buggy address is located 0 bytes inside of
 16-byte region [ffff8801c3b7a000, ffff8801c3b7a010)
The buggy address belongs to the page:
page:ffffea00070ede80 count:1 mapcount:0 mapping:          (null) index:0xffff8801c3b7aa80
flags: 0x8000000000000080(slab)
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801c3b79f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8801c3b79f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8801c3b7a000: fb fb fc fc fb fb fc fc fb fb fc fc fb fb fc fc
                   ^
 ffff8801c3b7a080: fb fb fc fc fb fb fc fc fb fb fc fc fb fb fc fc
 ffff8801c3b7a100: fb fb fc fc fb fb fc fc fb fb fc fc fb fb fc fc
==================================================================

Crashes (15):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/08/21 10:10 https://android.googlesource.com/kernel/common android-4.9 54068d61e7d8 95b5c82b .config console log report syz C ci-android-49-kasan-gce-root
2018/04/26 03:38 https://android.googlesource.com/kernel/common android-4.9 8c01d009ed72 73417389 .config console log report syz C ci-android-49-kasan-gce
2018/04/26 03:37 https://android.googlesource.com/kernel/common android-4.9 8c01d009ed72 73417389 .config console log report syz C ci-android-49-kasan-gce-root
2018/08/21 10:12 https://android.googlesource.com/kernel/common android-4.9 54068d61e7d8 95b5c82b .config console log report syz C ci-android-49-kasan-gce-386
2018/04/26 03:25 https://android.googlesource.com/kernel/common android-4.9 8c01d009ed72 73417389 .config console log report syz C ci-android-49-kasan-gce-386
2018/04/04 08:50 https://android.googlesource.com/kernel/common android-4.9 13b40d327b49 676bd07e .config console log report syz ci-android-49-kasan-gce
2018/04/04 08:32 https://android.googlesource.com/kernel/common android-4.9 13b40d327b49 676bd07e .config console log report syz ci-android-49-kasan-gce-386
2018/08/26 09:48 https://android.googlesource.com/kernel/common android-4.9 09eb2ba5ed0c 758cd203 .config console log report ci-android-49-kasan-gce
2018/08/25 08:57 https://android.googlesource.com/kernel/common android-4.9 09eb2ba5ed0c 9be5aa1d .config console log report ci-android-49-kasan-gce
2018/08/22 03:21 https://android.googlesource.com/kernel/common android-4.9 54068d61e7d8 95b5c82b .config console log report ci-android-49-kasan-gce
2018/08/16 01:22 https://android.googlesource.com/kernel/common android-4.9 f85543ba3c54 9ccc1d45 .config console log report ci-android-49-kasan-gce
2018/08/11 06:25 https://android.googlesource.com/kernel/common android-4.9 9dc978d43ec7 7a88b141 .config console log report ci-android-49-kasan-gce
2018/04/29 02:01 https://android.googlesource.com/kernel/common android-4.9 71fce1edd26d d5a5d045 .config console log report ci-android-49-kasan-gce
2018/04/24 15:52 https://android.googlesource.com/kernel/common android-4.9 320d53a9d07c 2bf86f40 .config console log report ci-android-49-kasan-gce
2018/04/26 03:07 https://android.googlesource.com/kernel/common android-4.9 8c01d009ed72 73417389 .config console log report ci-android-49-kasan-gce-386
* Struck through repros no longer work on HEAD.