syzbot


KASAN: use-after-free Read in scatterwalk_copychunks

Status: upstream: reported C repro on 2024/05/04 09:57
Subsystems: bcachefs
[Documentation on labels]
Reported-by: syzbot+8c4acf719c3fc41e8439@syzkaller.appspotmail.com
First crash: 200d, last: 7d14h
Cause bisection: introduced by (bisect log) :
commit dc6f2eb000d76ac8f93f4d59a8012ddfccca927a
Author: Kent Overstreet <kent.overstreet@linux.dev>
Date: Wed Apr 17 05:26:02 2024 +0000

  bcachefs: make btree read errors silent during scan

Crash: KASAN: use-after-free Read in scatterwalk_copychunks (log)
Repro: C syz .config
  
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [crypto?] KASAN: use-after-free Read in scatterwalk_copychunks 1 (3) 2024/05/05 00:35
Similar bugs (10)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream general protection fault in scatterwalk_copychunks (4) net crypto C done done 1341 334d 1345d 25/28 fixed on 2023/12/22 15:08
linux-4.14 KASAN: use-after-free Read in scatterwalk_copychunks C inconclusive 4 1386d 2040d 0/1 upstream: reported C repro on 2019/04/21 07:18
linux-4.19 KASAN: use-after-free Read in scatterwalk_copychunks C error 17 660d 1876d 0/1 upstream: reported C repro on 2019/10/03 04:34
linux-4.14 KASAN: slab-out-of-bounds Read in scatterwalk_copychunks C inconclusive 6 1394d 1897d 0/1 upstream: reported C repro on 2019/09/11 08:57
linux-4.14 general protection fault in scatterwalk_copychunks C error 204 648d 2040d 0/1 upstream: reported C repro on 2019/04/21 07:15
linux-5.15 BUG: unable to handle kernel paging request in scatterwalk_copychunks 3 574d 611d 0/3 auto-obsoleted due to no activity on 2023/08/23 09:08
linux-6.1 BUG: unable to handle kernel paging request in scatterwalk_copychunks 1 522d 522d 0/3 auto-obsoleted due to no activity on 2023/09/25 13:18
linux-4.19 general protection fault in scatterwalk_copychunks C error 152 649d 1980d 0/1 upstream: reported C repro on 2019/06/20 18:59
upstream general protection fault in scatterwalk_copychunks (5) crypto C done 2920 324d 330d 25/28 fixed on 2024/01/30 15:47
linux-4.19 KASAN: slab-out-of-bounds Read in scatterwalk_copychunks C error 5 1154d 1979d 0/1 upstream: reported C repro on 2019/06/21 13:46
Last patch testing requests (3)
Created Duration User Patch Repo Result
2024/11/09 07:26 21m retest repro linux-next report log
2024/11/09 07:13 13m retest repro upstream report log
2024/08/27 21:30 15m retest repro linux-next report log

Sample crash report:
bcachefs (loop0): Version upgrade required:
Version upgrade from 0.19: freespace to 1.7: mi_btree_bitmap incomplete
Doing incompatible version upgrade from 0.19: freespace to 1.13: inode_has_child_snapshots
  running recovery passes: check_allocations,check_alloc_info,check_lrus,check_btree_backpointers,check_backpointers_to_extents,check_extents_to_backpointers,check_alloc_to_lru_refs,bucket_gens_init,check_snapshot_trees,check_snapshots,check_subvols,check_subvol_children,delete_dead_snapshots,check_inodes,check_extents,check_indirect_extents,check_dirents,check_xattrs,check_root,check_unreachable_inodes,check_subvolume_structure,check_directory_structure,check_nlinks,set_fs_needs_rebalance
==================================================================
BUG: KASAN: use-after-free in memcpy_dir crypto/scatterwalk.c:23 [inline]
BUG: KASAN: use-after-free in scatterwalk_copychunks+0x1cc/0x460 crypto/scatterwalk.c:38
Read of size 40 at addr ffff888071260000 by task syz-executor214/5833

CPU: 1 UID: 0 PID: 5833 Comm: syz-executor214 Not tainted 6.12.0-rc6-syzkaller-00272-gda4373fbcf00 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 kasan_check_range+0x282/0x290 mm/kasan/generic.c:189
 __asan_memcpy+0x29/0x70 mm/kasan/shadow.c:105
 memcpy_dir crypto/scatterwalk.c:23 [inline]
 scatterwalk_copychunks+0x1cc/0x460 crypto/scatterwalk.c:38
 skcipher_next_slow+0x39d/0x480 crypto/skcipher.c:276
 skcipher_walk_next+0x634/0xba0 crypto/skcipher.c:361
 chacha_simd_stream_xor+0x67f/0xd10 arch/x86/crypto/chacha_glue.c:192
 do_encrypt_sg fs/bcachefs/checksum.c:108 [inline]
 do_encrypt+0x992/0xd70 fs/bcachefs/checksum.c:124
 bset_encrypt fs/bcachefs/btree_io.h:118 [inline]
 bch2_btree_node_read_done+0x17b4/0x5e90 fs/bcachefs/btree_io.c:1115
 btree_node_read_work+0x68b/0x1260 fs/bcachefs/btree_io.c:1327
 bch2_btree_node_read+0x2433/0x2a10
 __bch2_btree_root_read fs/bcachefs/btree_io.c:1753 [inline]
 bch2_btree_root_read+0x617/0x7a0 fs/bcachefs/btree_io.c:1775
 read_btree_roots+0x296/0x840 fs/bcachefs/recovery.c:523
 bch2_fs_recovery+0x2585/0x39d0 fs/bcachefs/recovery.c:853
 bch2_fs_start+0x356/0x5b0 fs/bcachefs/super.c:1036
 bch2_fs_get_tree+0xd68/0x1710 fs/bcachefs/fs.c:2170
 vfs_get_tree+0x90/0x2b0 fs/super.c:1814
 do_new_mount+0x2be/0xb40 fs/namespace.c:3507
 do_mount fs/namespace.c:3847 [inline]
 __do_sys_mount fs/namespace.c:4057 [inline]
 __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4034
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fd2c83dc9ea
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 5e 04 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fd2c8392088 EFLAGS: 00000282 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fd2c83920a0 RCX: 00007fd2c83dc9ea
RDX: 000000002000f700 RSI: 000000002000f680 RDI: 00007fd2c83920a0
RBP: 0000000000000004 R08: 00007fd2c83920e0 R09: 0037373737373737
R10: 0000000000000012 R11: 0000000000000282 R12: 00007fd2c83920e0
R13: 0000000000000012 R14: 0000000000000003 R15: 0000000001000000
 </TASK>

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x71260
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: f0(buddy)
raw: 00fff00000000000 ffffea0001c4b008 ffff88813fffc7a8 0000000000000000
raw: 0000000000000000 0000000000000005 00000000f0000000 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 5, migratetype Reclaimable, gfp_mask 0x452cd0(GFP_KERNEL_ACCOUNT|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_RECLAIMABLE), pid 5833, tgid 5831 (syz-executor214), ts 76310183556, free_ts 76441926427
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1537
 prep_new_page mm/page_alloc.c:1545 [inline]
 get_page_from_freelist+0x3033/0x3180 mm/page_alloc.c:3457
 __alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4733
 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:296 [inline]
 ___kmalloc_large_node+0x8b/0x1d0 mm/slub.c:4209
 __kmalloc_large_node_noprof+0x1a/0x80 mm/slub.c:4236
 __do_kmalloc_node mm/slub.c:4252 [inline]
 __kmalloc_node_noprof+0x2d2/0x440 mm/slub.c:4270
 __kvmalloc_node_noprof+0x72/0x190 mm/util.c:658
 btree_node_data_alloc+0xdb/0x260 fs/bcachefs/btree_cache.c:153
 __bch2_btree_node_mem_alloc+0x1d8/0x3e0 fs/bcachefs/btree_cache.c:198
 bch2_fs_btree_cache_init+0x26f/0x630 fs/bcachefs/btree_cache.c:653
 bch2_fs_alloc fs/bcachefs/super.c:916 [inline]
 bch2_fs_open+0x2aa4/0x2f80 fs/bcachefs/super.c:2064
 bch2_fs_get_tree+0x738/0x1710 fs/bcachefs/fs.c:2157
 vfs_get_tree+0x90/0x2b0 fs/super.c:1814
 do_new_mount+0x2be/0xb40 fs/namespace.c:3507
 do_mount fs/namespace.c:3847 [inline]
 __do_sys_mount fs/namespace.c:4057 [inline]
 __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4034
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
page last free pid 5833 tgid 5831 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1108 [inline]
 __free_pages_ok+0xa91/0xc70 mm/page_alloc.c:1250
 __folio_put+0x2c7/0x440 mm/swap.c:126
 folio_put include/linux/mm.h:1478 [inline]
 free_large_kmalloc+0x105/0x1c0 mm/slub.c:4698
 kfree+0x21c/0x440 mm/slub.c:4721
 btree_bounce_free fs/bcachefs/btree_io.c:112 [inline]
 bch2_btree_node_read_done+0x3c8a/0x5e90 fs/bcachefs/btree_io.c:1213
 btree_node_read_work+0x68b/0x1260 fs/bcachefs/btree_io.c:1327
 bch2_btree_node_read+0x2433/0x2a10
 __bch2_btree_root_read fs/bcachefs/btree_io.c:1753 [inline]
 bch2_btree_root_read+0x617/0x7a0 fs/bcachefs/btree_io.c:1775
 read_btree_roots+0x296/0x840 fs/bcachefs/recovery.c:523
 bch2_fs_recovery+0x2585/0x39d0 fs/bcachefs/recovery.c:853
 bch2_fs_start+0x356/0x5b0 fs/bcachefs/super.c:1036
 bch2_fs_get_tree+0xd68/0x1710 fs/bcachefs/fs.c:2170
 vfs_get_tree+0x90/0x2b0 fs/super.c:1814
 do_new_mount+0x2be/0xb40 fs/namespace.c:3507
 do_mount fs/namespace.c:3847 [inline]
 __do_sys_mount fs/namespace.c:4057 [inline]
 __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4034
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83

Memory state around the buggy address:
 ffff88807125ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88807125ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888071260000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                   ^
 ffff888071260080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888071260100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (36):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/09 18:28 upstream da4373fbcf00 6b856513 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs KASAN: use-after-free Read in scatterwalk_copychunks
2024/10/26 06:59 upstream c71f8fb4dc91 65e8686b .config console log report syz / log C [disk image (non-bootable)] [vmlinux] [kernel image] [mounted in repro] ci-snapshot-upstream-root KASAN: use-after-free Read in scatterwalk_copychunks
2024/05/04 09:26 linux-next 9221b2819b8a 610f2a54 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in scatterwalk_copychunks
2024/07/14 08:56 upstream 4d145e3f830b eaeb5c15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in scatterwalk_copychunks
2024/07/14 08:56 upstream 4d145e3f830b eaeb5c15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in scatterwalk_copychunks
2024/07/08 16:31 upstream 256abd8e550c cde64f7d .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in scatterwalk_copychunks
2024/07/06 17:21 upstream 1dd28064d416 2a40360c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in scatterwalk_copychunks
2024/07/03 17:15 upstream e9d22f7a6655 1ecfa2d8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in scatterwalk_copychunks
2024/06/20 03:06 upstream 2ccbdf43d5e7 41b7e219 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: use-after-free Read in scatterwalk_copychunks
2024/06/19 22:32 upstream 2ccbdf43d5e7 41b7e219 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: use-after-free Read in scatterwalk_copychunks
2024/06/10 06:09 upstream 83a7eefedc9b 82c05ab8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in scatterwalk_copychunks
2024/06/09 09:46 upstream 061d1af7b030 82c05ab8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in scatterwalk_copychunks
2024/05/24 15:11 upstream 8f6a15f095a6 8f98448e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in scatterwalk_copychunks
2024/11/13 15:46 upstream f1b785f4c787 4dfba277 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Read in scatterwalk_copychunks
2024/10/26 07:02 upstream c71f8fb4dc91 65e8686b .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Read in scatterwalk_copychunks
2024/10/26 06:40 upstream c71f8fb4dc91 65e8686b .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Read in scatterwalk_copychunks
2024/10/18 10:10 upstream 4d939780b705 666f77ed .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: use-after-free Read in scatterwalk_copychunks
2024/05/13 05:37 linux-next 75fa778d74b7 9026e142 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in scatterwalk_copychunks
2024/05/04 08:49 linux-next 9221b2819b8a 610f2a54 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in scatterwalk_copychunks
2024/08/10 17:46 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci c912bf709078 6f4edef4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: use-after-free Read in scatterwalk_copychunks
2024/08/04 07:18 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci c912bf709078 1786a2a8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: use-after-free Read in scatterwalk_copychunks
2024/07/19 02:45 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci c912bf709078 ee4e11c8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: use-after-free Read in scatterwalk_copychunks
2024/07/10 07:38 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci ef445d1539dd 79d68ada .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: use-after-free Read in scatterwalk_copychunks
2024/06/19 00:07 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci ac2193b4b460 639d6cdf .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: use-after-free Read in scatterwalk_copychunks
2024/06/14 14:32 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci ac2193b4b460 a9616ff5 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: use-after-free Read in scatterwalk_copychunks
2024/06/14 14:32 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci ac2193b4b460 a9616ff5 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: use-after-free Read in scatterwalk_copychunks
2024/06/09 06:31 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 8867bbd4a056 82c05ab8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: use-after-free Read in scatterwalk_copychunks
2024/07/13 01:12 upstream 975f3b6da180 eaeb5c15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in scatterwalk_copychunks
2024/06/05 08:08 upstream 32f88d65f01b e1e2c66e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in scatterwalk_copychunks
2024/05/29 13:28 upstream e0cce98fe279 34889ee3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in scatterwalk_copychunks
2024/11/12 10:31 upstream 2d5404caa8c7 75bb1b32 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-out-of-bounds Read in scatterwalk_copychunks
2024/05/22 22:09 linux-next 124cfbcd6d18 4d098039 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in scatterwalk_copychunks
2024/08/10 10:13 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci c912bf709078 6f4edef4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: slab-use-after-free Read in scatterwalk_copychunks
2024/07/22 16:55 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci c912bf709078 f063dfd9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: slab-use-after-free Read in scatterwalk_copychunks
2024/07/14 04:43 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci c912bf709078 eaeb5c15 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: slab-use-after-free Read in scatterwalk_copychunks
2024/07/13 20:51 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci c912bf709078 eaeb5c15 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: slab-use-after-free Read in scatterwalk_copychunks
* Struck through repros no longer work on HEAD.