syzbot


KASAN: use-after-free Read in tomoyo_path_matches_pattern

Status: auto-closed as invalid on 2021/02/27 09:08
Subsystems: tomoyo
[Documentation on labels]
Reported-by: syzbot+5c77c3285684d0ad9886@syzkaller.appspotmail.com
First crash: 1175d, last: 1175d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in tomoyo_path_matches_pattern+0x278/0x280 security/tomoyo/util.c:941
Read of size 8 at addr ffff888012a6e218 by task syz-executor.4/14176

CPU: 1 PID: 14176 Comm: syz-executor.4 Not tainted 5.10.0-next-20201223-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x107/0x163 lib/dump_stack.c:120
 print_address_description.constprop.0.cold+0x5b/0x2f8 mm/kasan/report.c:230
 __kasan_report mm/kasan/report.c:396 [inline]
 kasan_report.cold+0x79/0xd5 mm/kasan/report.c:413
 tomoyo_path_matches_pattern+0x278/0x280 security/tomoyo/util.c:941
 tomoyo_compare_name_union security/tomoyo/file.c:87 [inline]
 tomoyo_compare_name_union security/tomoyo/file.c:82 [inline]
 tomoyo_check_path_acl security/tomoyo/file.c:260 [inline]
 tomoyo_check_path_acl+0x164/0x1f0 security/tomoyo/file.c:252
 tomoyo_check_acl+0x13c/0x450 security/tomoyo/domain.c:175
 tomoyo_path_permission security/tomoyo/file.c:586 [inline]
 tomoyo_path_permission+0x1ff/0x3a0 security/tomoyo/file.c:573
 tomoyo_path_perm+0x2f0/0x400 security/tomoyo/file.c:838
 security_inode_getattr+0xcf/0x140 security/security.c:1280
 vfs_getattr fs/stat.c:121 [inline]
 vfs_fstat+0x43/0xb0 fs/stat.c:146
 __do_sys_newfstat+0x81/0x100 fs/stat.c:386
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x45d604
Code: c0 d4 ff ff ff 64 c7 00 16 00 00 00 b8 ff ff ff ff c3 0f 1f 40 00 83 ff 01 89 f0 77 31 48 63 f8 48 89 d6 b8 05 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 04 f3 c3 66 90 48 c7 c2 d4 ff ff ff f7 d8 64
RSP: 002b:00007ffc9b6418b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000005
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 000000000045d604
RDX: 00007ffc9b6418c0 RSI: 00007ffc9b6418c0 RDI: 0000000000000003
RBP: 000000000009dc31 R08: 0000000000000000 R09: 0000000001ad9940
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffc9b642ac0
R13: 0000000000000002 R14: 0000000000000000 R15: 000000000009db78

Allocated by task 11335:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:404 [inline]
 ____kasan_kmalloc mm/kasan/common.c:435 [inline]
 ____kasan_kmalloc.constprop.0+0xa0/0xd0 mm/kasan/common.c:407
 kmalloc include/linux/slab.h:557 [inline]
 kzalloc include/linux/slab.h:682 [inline]
 tomoyo_get_name+0x234/0x480 security/tomoyo/memory.c:173
 tomoyo_parse_name_union+0xbc/0x160 security/tomoyo/util.c:260
 tomoyo_update_path_acl security/tomoyo/file.c:395 [inline]
 tomoyo_write_file+0x4c0/0x7f0 security/tomoyo/file.c:1022
 tomoyo_write_domain2+0x116/0x1d0 security/tomoyo/common.c:1152
 tomoyo_add_entry security/tomoyo/common.c:2042 [inline]
 tomoyo_supervisor+0xbc4/0xef0 security/tomoyo/common.c:2103
 tomoyo_audit_path_log security/tomoyo/file.c:168 [inline]
 tomoyo_path_permission security/tomoyo/file.c:587 [inline]
 tomoyo_path_permission+0x270/0x3a0 security/tomoyo/file.c:573
 tomoyo_path_perm+0x39e/0x400 security/tomoyo/file.c:838
 tomoyo_path_symlink+0x94/0xe0 security/tomoyo/tomoyo.c:200
 security_path_symlink+0xdf/0x150 security/security.c:1111
 do_symlinkat+0x123/0x2c0 fs/namei.c:3987
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 19145:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:355
 ____kasan_slab_free.part.0+0xe1/0x110 mm/kasan/common.c:365
 kasan_slab_free include/linux/kasan.h:188 [inline]
 slab_free_hook mm/slub.c:1548 [inline]
 slab_free_freelist_hook+0x82/0x1d0 mm/slub.c:1586
 slab_free mm/slub.c:3157 [inline]
 kfree+0xe5/0x5c0 mm/slub.c:4156
 bdev_free_inode+0x57/0x80 fs/block_dev.c:787
 i_callback+0x3f/0x70 fs/inode.c:222
 rcu_do_batch kernel/rcu/tree.c:2489 [inline]
 rcu_core+0x5eb/0xf00 kernel/rcu/tree.c:2723
 __do_softirq+0x2a5/0x9f7 kernel/softirq.c:343

The buggy address belongs to the object at ffff888012a6e200
 which belongs to the cache kmalloc-128 of size 128
The buggy address is located 24 bytes inside of
 128-byte region [ffff888012a6e200, ffff888012a6e280)
The buggy address belongs to the page:
page:00000000cfea1e35 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x12a6e
flags: 0xfff00000000200(slab)
raw: 00fff00000000200 ffffea00009cf8c0 0000000300000003 ffff888010041640
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888012a6e100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888012a6e180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888012a6e200: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff888012a6e280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888012a6e300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/12/29 09:07 linux-next d7a03a44a5e9 8259d56c .config console log report info ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.