syzbot


KASAN: invalid-free in p9stat_free

Status: fixed on 2018/11/12 21:25
Subsystems: v9fs
[Documentation on labels]
Reported-by: syzbot+d4252148d198410b864f@syzkaller.appspotmail.com
Fix commit: 62e3941776fe 9p: clear dangling pointers in p9stat_free 81c99089bce6 v9fs_dir_readdir: fix double-free on p9stat_read error
First crash: 2291d, last: 2291d
Discussions (19)
Title Replies (including bot) Last reply
[PATCH 4.19 000/110] 4.19.6-stable review 142 (142) 2018/12/14 17:42
[PATCH 4.14 000/100] 4.14.85-stable review 116 (116) 2018/12/03 11:38
[PATCH 3.18 00/83] 3.18.128-stable review 97 (97) 2018/12/02 20:32
[PATCH 4.9 00/92] 4.9.142-stable review 102 (102) 2018/11/30 22:28
[PATCH 4.4 00/86] 4.4.166-stable review 92 (92) 2018/11/30 22:27
[PATCH 3.18 00/90] 3.18.126-stable review 102 (102) 2018/11/22 06:30
[PATCH 4.19 000/205] 4.19.3-stable review 214 (214) 2018/11/21 08:05
[PATCH 4.4 000/160] 4.4.164-stable review 169 (169) 2018/11/21 07:59
[PATCH 4.18 000/171] 4.18.20-stable review 176 (176) 2018/11/20 20:40
[PATCH 4.14 000/124] 4.14.82-stable review 131 (131) 2018/11/20 20:39
[PATCH 4.9 00/83] 4.9.138-stable review 89 (89) 2018/11/20 20:39
[PATCH AUTOSEL 4.14 01/30] mm/vmstat.c: assert that vmstat_text is in sync with stat_items_size 33 (33) 2018/11/11 22:07
[PATCH AUTOSEL 4.19 01/57] mm: thp: fix MADV_DONTNEED vs migrate_misplaced_transhuge_page race condition 58 (58) 2018/11/05 22:26
[PATCH AUTOSEL 3.18 01/13] mm/vmstat.c: assert that vmstat_text is in sync with stat_items_size 13 (13) 2018/11/04 13:54
[PATCH AUTOSEL 4.4 01/15] mm/vmstat.c: assert that vmstat_text is in sync with stat_items_size 15 (15) 2018/11/04 13:54
[PATCH AUTOSEL 4.9 01/21] mm/vmstat.c: assert that vmstat_text is in sync with stat_items_size 21 (21) 2018/11/04 13:53
[PATCH AUTOSEL 4.18 01/45] mm: thp: fix MADV_DONTNEED vs migrate_misplaced_transhuge_page race condition 45 (45) 2018/11/04 13:52
[PATCH 1/2] v9fs_dir_readdir: fix double-free on p9stat_read error 2 (2) 2018/08/27 22:48
KASAN: invalid-free in p9stat_free 3 (4) 2018/08/27 22:40
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-49 KASAN: invalid-free in p9stat_free C 1 2291d 2060d 0/3 public: reported C repro on 2019/04/14 08:51

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: double-free or invalid-free in p9stat_free+0x35/0x100 net/9p/protocol.c:48

CPU: 0 PID: 4442 Comm: syz-executor725 Not tainted 4.18.0+ #209
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+0x1c9/0x2b4 lib/dump_stack.c:113
 print_address_description+0x6c/0x20b mm/kasan/report.c:256
 kasan_report_invalid_free+0x64/0xa0 mm/kasan/report.c:336
 __kasan_slab_free+0x150/0x170 mm/kasan/kasan.c:501
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xd9/0x210 mm/slab.c:3813
 p9stat_free+0x35/0x100 net/9p/protocol.c:48
 v9fs_dir_readdir+0x68e/0xbc0 fs/9p/vfs_dir.c:153
 iterate_dir+0x48b/0x5d0 fs/readdir.c:51
 __do_sys_getdents fs/readdir.c:231 [inline]
 __se_sys_getdents fs/readdir.c:212 [inline]
 __x64_sys_getdents+0x29f/0x510 fs/readdir.c:212
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4406a9
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 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 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fffc67864f8 EFLAGS: 00000217 ORIG_RAX: 000000000000004e
RAX: ffffffffffffffda RBX: 0030656c69662f2e RCX: 00000000004406a9
RDX: 0000000000000008 RSI: 0000000020000180 RDI: 0000000000000005
RBP: 64663d736e617274 R08: 0000000000401f30 R09: 0000000000401f30
R10: 0000000000401f30 R11: 0000000000000217 R12: 0000000000401f30
R13: 0000000000401fc0 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 4442:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc4/0xe0 mm/kasan/kasan.c:553
 __do_kmalloc mm/slab.c:3718 [inline]
 __kmalloc+0x14e/0x720 mm/slab.c:3727
 kmalloc include/linux/slab.h:518 [inline]
 p9pdu_vreadf net/9p/protocol.c:157 [inline]
 p9pdu_readf+0x526/0x2170 net/9p/protocol.c:536
 p9pdu_vreadf net/9p/protocol.c:208 [inline]
 p9pdu_readf+0xd5c/0x2170 net/9p/protocol.c:536
 p9stat_read+0x194/0x5d0 net/9p/protocol.c:565
 v9fs_dir_readdir+0x63d/0xbc0 fs/9p/vfs_dir.c:149
 iterate_dir+0x48b/0x5d0 fs/readdir.c:51
 __do_sys_getdents fs/readdir.c:231 [inline]
 __se_sys_getdents fs/readdir.c:212 [inline]
 __x64_sys_getdents+0x29f/0x510 fs/readdir.c:212
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 4442:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xd9/0x210 mm/slab.c:3813
 p9stat_free+0x35/0x100 net/9p/protocol.c:48
 p9pdu_vreadf net/9p/protocol.c:220 [inline]
 p9pdu_readf+0xd90/0x2170 net/9p/protocol.c:536
 p9stat_read+0x194/0x5d0 net/9p/protocol.c:565
 v9fs_dir_readdir+0x63d/0xbc0 fs/9p/vfs_dir.c:149
 iterate_dir+0x48b/0x5d0 fs/readdir.c:51
 __do_sys_getdents fs/readdir.c:231 [inline]
 __se_sys_getdents fs/readdir.c:212 [inline]
 __x64_sys_getdents+0x29f/0x510 fs/readdir.c:212
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8801d7975500
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 0 bytes inside of
 32-byte region [ffff8801d7975500, ffff8801d7975520)
The buggy address belongs to the page:
page:ffffea00075e5d40 count:1 mapcount:0 mapping:ffff8801dac001c0 index:0xffff8801d7975fc1
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffffea00075e6408 ffffea0006c2f848 ffff8801dac001c0
raw: ffff8801d7975fc1 ffff8801d7975000 000000010000002d 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801d7975400: 00 00 00 fc fc fc fc fc fb fb fb fb fc fc fc fc
 ffff8801d7975480: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
>ffff8801d7975500: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
                   ^
 ffff8801d7975580: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
 ffff8801d7975600: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/08/26 14:35 upstream 2923b27e5424 758cd203 .config console log report syz C ci-upstream-kasan-gce-root
2018/08/26 13:10 linux-next e27bc174c9c6 758cd203 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/08/26 10:47 linux-next e27bc174c9c6 758cd203 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.