syzbot


KASAN: use-after-free Read in btrfs_scan_one_device

Status: fixed on 2020/12/31 01:42
Reported-by: syzbot+4bbc210499f15664aff6@syzkaller.appspotmail.com
Fix commit: aec62fa475af btrfs: don't access possibly stale fs_info data for printing duplicate device
First crash: 1526d, last: 1451d
Fix bisection: fixed by (bisect log) :
commit aec62fa475afe706ae210c28eca38ef62ac19dbc
Author: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Date: Wed Nov 18 09:03:26 2020 +0000

  btrfs: don't access possibly stale fs_info data for printing duplicate device

  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in btrfs_scan_one_device btrfs C error 70 1457d 1523d 19/28 fixed on 2021/03/10 01:49
upstream KASAN: use-after-free Read in btrfs_scan_one_device (2) btrfs C 2 997d 994d 22/28 fixed on 2023/02/24 13:50

Sample crash report:
BTRFS error (device loop5): open_ctree failed
BTRFS info (device loop5): disk space caching is enabled
BTRFS info (device loop5): has skinny extents
==================================================================
BUG: KASAN: use-after-free in btrfs_printk+0x34f/0x3d0 fs/btrfs/super.c:215
Read of size 8 at addr ffff88809e9ce4e0 by task syz-executor414/9105

CPU: 0 PID: 9105 Comm: syz-executor414 Not tainted 4.19.160-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+0x1fc/0x2fe lib/dump_stack.c:118
 print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
 kasan_report_error.cold+0x8a/0x1c7 mm/kasan/report.c:354
 kasan_report mm/kasan/report.c:412 [inline]
 __asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433
 btrfs_printk+0x34f/0x3d0 fs/btrfs/super.c:215
 device_list_add.cold+0x1a0/0x376 fs/btrfs/volumes.c:860
 btrfs_scan_one_device+0x33f/0xd00 fs/btrfs/volumes.c:1263
 btrfs_mount_root+0x9df/0x1830 fs/btrfs/super.c:1577
 mount_fs+0xa3/0x30c fs/super.c:1261
 vfs_kern_mount.part.0+0x68/0x470 fs/namespace.c:961
 vfs_kern_mount+0x3c/0x60 fs/namespace.c:951
 btrfs_mount+0x23a/0xa93 fs/btrfs/super.c:1681
 mount_fs+0xa3/0x30c fs/super.c:1261
 vfs_kern_mount.part.0+0x68/0x470 fs/namespace.c:961
 vfs_kern_mount fs/namespace.c:951 [inline]
 do_new_mount fs/namespace.c:2469 [inline]
 do_mount+0x113c/0x2f10 fs/namespace.c:2799
 ksys_mount+0xcf/0x130 fs/namespace.c:3015
 __do_sys_mount fs/namespace.c:3029 [inline]
 __se_sys_mount fs/namespace.c:3026 [inline]
 __x64_sys_mount+0xba/0x150 fs/namespace.c:3026
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x44e03a
Code: b8 08 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 ad a0 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 8a a0 fb ff c3 66 0f 1f 84 00 00 00 00 00
RSP: 002b:00007fa01c4cfbf8 EFLAGS: 00000293 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 000000000044e03a
RDX: 0000000020000000 RSI: 0000000020000100 RDI: 00007fa01c4cfc10
RBP: 00007fa01c4cfc10 R08: 00007fa01c4cfc50 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000293 R12: 000000000000001e
R13: 00007fa01c4cfc50 R14: 00007fa01c4d06d0 R15: 0000000000000005

Allocated by task 8822:
 __do_kmalloc_node mm/slab.c:3689 [inline]
 __kmalloc_node+0x4c/0x70 mm/slab.c:3696
 kmalloc_node include/linux/slab.h:557 [inline]
 kvmalloc_node+0xb4/0xf0 mm/util.c:423
 kvmalloc include/linux/mm.h:577 [inline]
 kvzalloc include/linux/mm.h:585 [inline]
 btrfs_mount_root+0x13f/0x1830 fs/btrfs/super.c:1556
 mount_fs+0xa3/0x30c fs/super.c:1261
 vfs_kern_mount.part.0+0x68/0x470 fs/namespace.c:961
 vfs_kern_mount+0x3c/0x60 fs/namespace.c:951
 btrfs_mount+0x23a/0xa93 fs/btrfs/super.c:1681
 mount_fs+0xa3/0x30c fs/super.c:1261
 vfs_kern_mount.part.0+0x68/0x470 fs/namespace.c:961
 vfs_kern_mount fs/namespace.c:951 [inline]
 do_new_mount fs/namespace.c:2469 [inline]
 do_mount+0x113c/0x2f10 fs/namespace.c:2799
 ksys_mount+0xcf/0x130 fs/namespace.c:3015
 __do_sys_mount fs/namespace.c:3029 [inline]
 __se_sys_mount fs/namespace.c:3026 [inline]
 __x64_sys_mount+0xba/0x150 fs/namespace.c:3026
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8822:
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcc/0x210 mm/slab.c:3822
 kvfree+0x59/0x60 mm/util.c:452
 deactivate_locked_super+0x94/0x160 fs/super.c:329
 btrfs_mount_root+0x10a0/0x1830 fs/btrfs/super.c:1623
 mount_fs+0xa3/0x30c fs/super.c:1261
 vfs_kern_mount.part.0+0x68/0x470 fs/namespace.c:961
 vfs_kern_mount+0x3c/0x60 fs/namespace.c:951
 btrfs_mount+0x23a/0xa93 fs/btrfs/super.c:1681
 mount_fs+0xa3/0x30c fs/super.c:1261
 vfs_kern_mount.part.0+0x68/0x470 fs/namespace.c:961
 vfs_kern_mount fs/namespace.c:951 [inline]
 do_new_mount fs/namespace.c:2469 [inline]
 do_mount+0x113c/0x2f10 fs/namespace.c:2799
 ksys_mount+0xcf/0x130 fs/namespace.c:3015
 __do_sys_mount fs/namespace.c:3029 [inline]
 __se_sys_mount fs/namespace.c:3026 [inline]
 __x64_sys_mount+0xba/0x150 fs/namespace.c:3026
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809e9cdec0
 which belongs to the cache kmalloc-8192 of size 8192
The buggy address is located 1568 bytes inside of
 8192-byte region [ffff88809e9cdec0, ffff88809e9cfec0)
The buggy address belongs to the page:
page:ffffea00027a7300 count:1 mapcount:0 mapping:ffff88813bff2080 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffffea0002779308 ffffea0002600208 ffff88813bff2080
raw: 0000000000000000 ffff88809e9cdec0 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809e9ce380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809e9ce400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88809e9ce480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                       ^
 ffff88809e9ce500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809e9ce580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (43):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/11/28 23:03 linux-4.19.y 0c88e405c97e 3c7136c0 .config console log report syz C ci2-linux-4-19
2020/11/14 14:26 linux-4.19.y 31acccdc8774 1bf9a662 .config console log report syz C ci2-linux-4-19
2020/11/09 08:20 linux-4.19.y b94de4d19498 cba33199 .config console log report syz C ci2-linux-4-19
2020/11/08 09:54 linux-4.19.y b94de4d19498 cba33199 .config console log report syz C ci2-linux-4-19
2020/10/31 19:58 linux-4.19.y f5d8eef067ac 8bc4594f .config console log report syz C ci2-linux-4-19
2020/10/05 09:23 linux-4.19.y b09c34517e1a 5ef9c291 .config console log report syz C ci2-linux-4-19
2020/09/25 04:45 linux-4.19.y d09b80172c22 54289b08 .config console log report syz C ci2-linux-4-19
2020/09/24 20:04 linux-4.19.y d09b80172c22 54289b08 .config console log report syz C ci2-linux-4-19
2020/09/21 19:29 linux-4.19.y 015e94d0e37b c81d99c8 .config console log report syz C ci2-linux-4-19
2020/11/30 21:40 linux-4.19.y 0c88e405c97e 76831598 .config console log report info ci2-linux-4-19
2020/11/28 00:26 linux-4.19.y 0c88e405c97e 486f93ef .config console log report info ci2-linux-4-19
2020/11/27 10:28 linux-4.19.y 0c88e405c97e 5018c946 .config console log report info ci2-linux-4-19
2020/11/27 05:18 linux-4.19.y 0c88e405c97e 5018c946 .config console log report info ci2-linux-4-19
2020/11/25 23:57 linux-4.19.y 0c88e405c97e 3f581b43 .config console log report info ci2-linux-4-19
2020/11/24 23:12 linux-4.19.y 0c88e405c97e e34b696c .config console log report info ci2-linux-4-19
2020/11/22 19:16 linux-4.19.y 76bda503e640 0d27f508 .config console log report info ci2-linux-4-19
2020/11/22 19:01 linux-4.19.y 76bda503e640 0d27f508 .config console log report info ci2-linux-4-19
2020/11/21 08:21 linux-4.19.y 2c746135a12e 68068804 .config console log report info ci2-linux-4-19
2020/11/19 22:30 linux-4.19.y 2c746135a12e 0767f13f .config console log report info ci2-linux-4-19
2020/11/16 11:02 linux-4.19.y 31acccdc8774 1bf9a662 .config console log report info ci2-linux-4-19
2020/11/07 08:20 linux-4.19.y b94de4d19498 cba33199 .config console log report info ci2-linux-4-19
2020/11/04 08:16 linux-4.19.y f5d8eef067ac cba33199 .config console log report info ci2-linux-4-19
2020/11/01 01:23 linux-4.19.y f5d8eef067ac 8bc4594f .config console log report info ci2-linux-4-19
2020/10/31 13:10 linux-4.19.y f5d8eef067ac 8bc4594f .config console log report info ci2-linux-4-19
2020/10/30 16:06 linux-4.19.y f5d8eef067ac a6e3ac3b .config console log report info ci2-linux-4-19
2020/10/29 17:56 linux-4.19.y 79524e8c64bd a0c7169a .config console log report info ci2-linux-4-19
2020/10/27 05:46 linux-4.19.y ad326970d25c 8b3eaf58 .config console log report info ci2-linux-4-19
2020/10/24 17:27 linux-4.19.y ad326970d25c a1839e81 .config console log report info ci2-linux-4-19
2020/10/24 09:04 linux-4.19.y ad326970d25c 2bb6666c .config console log report info ci2-linux-4-19
2020/10/24 02:07 linux-4.19.y ad326970d25c 2bb6666c .config console log report info ci2-linux-4-19
2020/10/23 10:24 linux-4.19.y ad326970d25c 4e740c00 .config console log report info ci2-linux-4-19
2020/10/19 05:26 linux-4.19.y ad326970d25c fea47c01 .config console log report info ci2-linux-4-19
2020/10/17 18:13 linux-4.19.y ad326970d25c fea47c01 .config console log report info ci2-linux-4-19
2020/10/14 18:09 linux-4.19.y a1b977b49b66 fc7735a2 .config console log report info ci2-linux-4-19
2020/10/13 15:38 linux-4.19.y a1b977b49b66 bd69ee0d .config console log report info ci2-linux-4-19
2020/10/09 18:19 linux-4.19.y a1b977b49b66 fa79ed2a .config console log report info ci2-linux-4-19
2020/10/09 14:57 linux-4.19.y a1b977b49b66 fa79ed2a .config console log report info ci2-linux-4-19
2020/10/08 07:43 linux-4.19.y a1b977b49b66 1880b4a9 .config console log report info ci2-linux-4-19
2020/10/01 18:09 linux-4.19.y b09c34517e1a 4103fce0 .config console log report info ci2-linux-4-19
2020/09/27 22:18 linux-4.19.y 10ad6cfd5736 5dd8aee8 .config console log report info ci2-linux-4-19
2020/09/24 11:52 linux-4.19.y d09b80172c22 54289b08 .config console log report info ci2-linux-4-19
2020/09/20 15:19 linux-4.19.y 015e94d0e37b 9564d2e9 .config console log report info ci2-linux-4-19
2020/09/16 16:02 linux-4.19.y a87f96283793 77507d02 .config console log report info ci2-linux-4-19
* Struck through repros no longer work on HEAD.