syzbot


KASAN: use-after-free Read in smk_write_relabel_self

Status: fixed on 2020/09/16 22:51
Subsystems: lsm
[Documentation on labels]
Reported-by: syzbot+e6416dabb497a650da40@syzkaller.appspotmail.com
Fix commit: beb4ee6770a8 Smack: fix use-after-free in smk_write_relabel_self()
First crash: 1589d, last: 1589d
Cause bisection: the issue happens on the oldest tested release (bisect log)
Crash: WARNING in sysfs_warn_dup (log)
Repro: C syz .config
  
Discussions (9)
Title Replies (including bot) Last reply
[PATCH 4.4 000/149] 4.4.233-rc1 review 163 (163) 2020/10/31 20:04
[PATCH 4.9 000/212] 4.9.233-rc1 review 220 (220) 2020/08/21 09:40
[PATCH 4.14 000/228] 4.14.194-rc1 review 234 (234) 2020/08/21 06:59
[PATCH 4.19 00/48] 4.19.139-rc1 review 61 (61) 2020/08/11 16:45
[PATCH 5.8 00/38] 5.8.1-rc1 review 46 (46) 2020/08/11 16:20
[PATCH 5.7 00/79] 5.7.15-rc1 review 83 (83) 2020/08/11 14:23
[PATCH 5.4 00/67] 5.4.58-rc1 review 71 (71) 2020/08/11 14:23
[PATCH] Smack: fix use-after-free in smk_write_relabel_self() 4 (4) 2020/07/21 00:57
KASAN: use-after-free Read in smk_write_relabel_self 0 (1) 2020/06/08 21:56

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in smk_destroy_label_list security/smack/smackfs.c:1975 [inline]
BUG: KASAN: use-after-free in smk_write_relabel_self+0x2f6/0x480 security/smack/smackfs.c:2748
Read of size 8 at addr ffff88809184bec0 by task syz-executor032/6852

CPU: 0 PID: 6852 Comm: syz-executor032 Not tainted 5.7.0-syzkaller #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+0x1e9/0x30e lib/dump_stack.c:118
 print_address_description+0x66/0x5a0 mm/kasan/report.c:383
 __kasan_report mm/kasan/report.c:513 [inline]
 kasan_report+0x132/0x1d0 mm/kasan/report.c:530
 smk_destroy_label_list security/smack/smackfs.c:1975 [inline]
 smk_write_relabel_self+0x2f6/0x480 security/smack/smackfs.c:2748
 __vfs_write+0x9c/0x6e0 fs/read_write.c:495
 __kernel_write+0x120/0x350 fs/read_write.c:516
 write_pipe_buf+0xf9/0x150 fs/splice.c:799
 splice_from_pipe_feed fs/splice.c:502 [inline]
 __splice_from_pipe+0x351/0x8b0 fs/splice.c:626
 splice_from_pipe fs/splice.c:661 [inline]
 default_file_splice_write fs/splice.c:811 [inline]
 do_splice_from fs/splice.c:847 [inline]
 direct_splice_actor+0x1eb/0x2a0 fs/splice.c:1016
 splice_direct_to_actor+0x4a2/0xb60 fs/splice.c:971
 do_splice_direct+0x201/0x340 fs/splice.c:1059
 do_sendfile+0x809/0xfe0 fs/read_write.c:1521
 __do_sys_sendfile64 fs/read_write.c:1582 [inline]
 __se_sys_sendfile64 fs/read_write.c:1568 [inline]
 __x64_sys_sendfile64+0x164/0x1a0 fs/read_write.c:1568
 do_syscall_64+0xf3/0x1b0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x446a29
Code: e8 bc b4 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 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 ab 08 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f662054fdb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000028
RAX: ffffffffffffffda RBX: 00000000006dbc88 RCX: 0000000000446a29
RDX: 0000000000000000 RSI: 0000000000000005 RDI: 0000000000000006
RBP: 00000000006dbc80 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000100000064 R11: 0000000000000246 R12: 00000000006dbc8c
R13: 00007fffa294e1ef R14: 00007f66205509c0 R15: 0000000000000001

Allocated by task 6850:
 save_stack mm/kasan/common.c:48 [inline]
 set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc+0x103/0x140 mm/kasan/common.c:494
 kmem_cache_alloc_trace+0x234/0x300 mm/slab.c:3551
 kmalloc include/linux/slab.h:555 [inline]
 kzalloc include/linux/slab.h:669 [inline]
 smk_parse_label_list+0xff/0x280 security/smack/smackfs.c:1955
 smk_write_relabel_self+0x190/0x480 security/smack/smackfs.c:2744
 __vfs_write+0x9c/0x6e0 fs/read_write.c:495
 __kernel_write+0x120/0x350 fs/read_write.c:516
 write_pipe_buf+0xf9/0x150 fs/splice.c:799
 splice_from_pipe_feed fs/splice.c:502 [inline]
 __splice_from_pipe+0x351/0x8b0 fs/splice.c:626
 splice_from_pipe fs/splice.c:661 [inline]
 default_file_splice_write fs/splice.c:811 [inline]
 do_splice_from fs/splice.c:847 [inline]
 direct_splice_actor+0x1eb/0x2a0 fs/splice.c:1016
 splice_direct_to_actor+0x4a2/0xb60 fs/splice.c:971
 do_splice_direct+0x201/0x340 fs/splice.c:1059
 do_sendfile+0x809/0xfe0 fs/read_write.c:1521
 __do_sys_sendfile64 fs/read_write.c:1582 [inline]
 __se_sys_sendfile64 fs/read_write.c:1568 [inline]
 __x64_sys_sendfile64+0x164/0x1a0 fs/read_write.c:1568
 do_syscall_64+0xf3/0x1b0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3

Freed by task 6850:
 save_stack mm/kasan/common.c:48 [inline]
 set_track mm/kasan/common.c:56 [inline]
 kasan_set_free_info mm/kasan/common.c:316 [inline]
 __kasan_slab_free+0x114/0x170 mm/kasan/common.c:455
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x10a/0x220 mm/slab.c:3757
 smk_destroy_label_list security/smack/smackfs.c:1976 [inline]
 smk_write_relabel_self+0x302/0x480 security/smack/smackfs.c:2748
 __vfs_write+0x9c/0x6e0 fs/read_write.c:495
 __kernel_write+0x120/0x350 fs/read_write.c:516
 write_pipe_buf+0xf9/0x150 fs/splice.c:799
 splice_from_pipe_feed fs/splice.c:502 [inline]
 __splice_from_pipe+0x351/0x8b0 fs/splice.c:626
 splice_from_pipe fs/splice.c:661 [inline]
 default_file_splice_write fs/splice.c:811 [inline]
 do_splice_from fs/splice.c:847 [inline]
 direct_splice_actor+0x1eb/0x2a0 fs/splice.c:1016
 splice_direct_to_actor+0x4a2/0xb60 fs/splice.c:971
 do_splice_direct+0x201/0x340 fs/splice.c:1059
 do_sendfile+0x809/0xfe0 fs/read_write.c:1521
 __do_sys_sendfile64 fs/read_write.c:1582 [inline]
 __se_sys_sendfile64 fs/read_write.c:1568 [inline]
 __x64_sys_sendfile64+0x164/0x1a0 fs/read_write.c:1568
 do_syscall_64+0xf3/0x1b0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3

The buggy address belongs to the object at ffff88809184bec0
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 0 bytes inside of
 32-byte region [ffff88809184bec0, ffff88809184bee0)
The buggy address belongs to the page:
page:ffffea00024612c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88809184bfc1
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea00029a8788 ffffea0002a351c8 ffff8880aa4001c0
raw: ffff88809184bfc1 ffff88809184b000 000000010000003f 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809184bd80: 00 00 00 fc fc fc fc fc fb fb fb fb fc fc fc fc
 ffff88809184be00: 00 fc fc fc fc fc fc fc fb fb fb fb fc fc fc fc
>ffff88809184be80: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
                                           ^
 ffff88809184bf00: fb fb fb fb fc fc fc fc 00 00 00 fc fc fc fc fc
 ffff88809184bf80: fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/06/04 22:28 upstream acf25aa66371 6720fdef .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/06/04 21:54 upstream acf25aa66371 6720fdef .config console log report ci-upstream-kasan-gce-smack-root
* Struck through repros no longer work on HEAD.