syzbot


KASAN: out-of-bounds Read in leaf_paste_entries (2)

Status: upstream: reported C repro on 2021/12/13 19:20
Reported-by: syzbot+38b79774b6c990637f95@syzkaller.appspotmail.com
First crash: 321d, last: 3d14h

Cause bisection: the issue happens on the oldest tested release (bisect log)
Crash: KASAN: out-of-bounds Read in leaf_paste_entries (log)
Repro: C syz .config

Fix bisection: the fix commit could be any of (bisect log):
  2585cf9dfaad Linux 5.16-rc5
  1612c382ffbd Merge tag 'x86-urgent-2022-08-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
similar bugs (3):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: out-of-bounds Read in leaf_paste_entries C error 14 2d21h 683d 0/1 upstream: reported C repro on 2020/11/14 23:23
linux-4.14 KASAN: out-of-bounds Read in leaf_paste_entries C error 10 2d04h 724d 0/1 upstream: reported C repro on 2020/10/05 14:11
upstream KASAN: out-of-bounds Read in leaf_paste_entries C inconclusive 8 355d 586d 22/24 fixed on 2021/11/10 00:50

Sample crash report:
REISERFS warning:  read_super_block: reiserfs filesystem is deprecated and scheduled to be removed from the kernel in 2025
REISERFS (device loop0): found reiserfs format "3.6" with non-standard journal
REISERFS (device loop0): using ordered data mode
reiserfs: using flush barriers
REISERFS (device loop0): journal params: device loop0, size 512, journal first block 18, max trans len 256, max batch 225, max commit age 30, max trans age 30
REISERFS (device loop0): checking transaction log (loop0)
REISERFS (device loop0): Using rupasov hash to sort names
==================================================================
BUG: KASAN: out-of-bounds in leaf_paste_entries+0x9b8/0x1440 fs/reiserfs/lbalance.c:1377
Read of size 18446744073709551585 at addr ffff8880bff33fa4 by task syz-executor360/3615

CPU: 0 PID: 3615 Comm: syz-executor360 Not tainted 6.0.0-rc6-syzkaller-00321-g105a36f3694e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106
 print_address_description+0x65/0x4b0 mm/kasan/report.c:317
 print_report+0x108/0x1f0 mm/kasan/report.c:433
 kasan_report+0xc3/0xf0 mm/kasan/report.c:495
 kasan_check_range+0x2a7/0x2e0 mm/kasan/generic.c:189
 memmove+0x25/0x60 mm/kasan/shadow.c:54
 leaf_paste_entries+0x9b8/0x1440 fs/reiserfs/lbalance.c:1377
 balance_leaf_finish_node_paste_dirent fs/reiserfs/do_balan.c:1295 [inline]
 balance_leaf_finish_node_paste fs/reiserfs/do_balan.c:1321 [inline]
 balance_leaf_finish_node fs/reiserfs/do_balan.c:1364 [inline]
 balance_leaf+0xbbf3/0x123a0 fs/reiserfs/do_balan.c:1452
 do_balance+0x2d6/0x8d0 fs/reiserfs/do_balan.c:1888
 reiserfs_paste_into_item+0x740/0x880 fs/reiserfs/stree.c:2159
 reiserfs_add_entry+0xa26/0xef0 fs/reiserfs/namei.c:567
 reiserfs_mkdir+0x682/0x8b0 fs/reiserfs/namei.c:860
 xattr_mkdir fs/reiserfs/xattr.c:76 [inline]
 create_privroot fs/reiserfs/xattr.c:882 [inline]
 reiserfs_xattr_init+0x34b/0x730 fs/reiserfs/xattr.c:1005
 reiserfs_fill_super+0x20b5/0x24a0 fs/reiserfs/super.c:2177
 mount_bdev+0x26c/0x3a0 fs/super.c:1400
 legacy_get_tree+0xea/0x180 fs/fs_context.c:610
 vfs_get_tree+0x88/0x270 fs/super.c:1530
 do_new_mount+0x289/0xad0 fs/namespace.c:3040
 do_mount fs/namespace.c:3383 [inline]
 __do_sys_mount fs/namespace.c:3591 [inline]
 __se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3568
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fdad486835a
Code: 83 c4 08 5b 5d c3 66 2e 0f 1f 84 00 00 00 00 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffddca95508 EFLAGS: 00000286 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007ffddca95560 RCX: 00007fdad486835a
RDX: 0000000020000000 RSI: 0000000020000100 RDI: 00007ffddca95520
RBP: 00007ffddca95520 R08: 00007ffddca95560 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000286 R12: 0000000020000290
R13: 0000000000000003 R14: 0000000000000004 R15: 0000000000000006
 </TASK>

The buggy address belongs to the physical page:
page:ffffea0002ffccc0 refcount:3 mapcount:0 mapping:ffff888140ccf5f8 index:0x213 pfn:0xbff33
memcg:ffff888012278000
aops:def_blk_aops ino:700000
flags: 0xfff00000002022(referenced|active|private|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000002022 0000000000000000 dead000000000122 ffff888140ccf5f8
raw: 0000000000000213 ffff888073ee2cb0 00000003ffffffff ffff888012278000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Movable, gfp_mask 0x148c48(GFP_NOFS|__GFP_NOFAIL|__GFP_COMP|__GFP_HARDWALL|__GFP_MOVABLE), pid 3615, tgid 3615 (syz-executor360), ts 40998401658, free_ts 40799566405
 prep_new_page mm/page_alloc.c:2532 [inline]
 get_page_from_freelist+0x742/0x7c0 mm/page_alloc.c:4283
 __alloc_pages+0x259/0x560 mm/page_alloc.c:5515
 folio_alloc+0x1a/0x50 mm/mempolicy.c:2280
 filemap_alloc_folio+0x7e/0x1c0 mm/filemap.c:970
 __filemap_get_folio+0x888/0x1250 mm/filemap.c:1970
 pagecache_get_page+0x2a/0x240 mm/folio-compat.c:104
 find_or_create_page include/linux/pagemap.h:613 [inline]
 grow_dev_page+0xba/0x920 fs/buffer.c:946
 grow_buffers fs/buffer.c:1011 [inline]
 __getblk_slow fs/buffer.c:1038 [inline]
 __getblk_gfp+0x16c/0x290 fs/buffer.c:1333
 sb_getblk include/linux/buffer_head.h:363 [inline]
 search_by_key+0x405/0x45b0 fs/reiserfs/stree.c:672
 reiserfs_read_locked_inode+0x223/0x2990 fs/reiserfs/inode.c:1549
 reiserfs_fill_super+0x128a/0x24a0 fs/reiserfs/super.c:2073
 mount_bdev+0x26c/0x3a0 fs/super.c:1400
 legacy_get_tree+0xea/0x180 fs/fs_context.c:610
 vfs_get_tree+0x88/0x270 fs/super.c:1530
 do_new_mount+0x289/0xad0 fs/namespace.c:3040
 do_mount fs/namespace.c:3383 [inline]
 __do_sys_mount fs/namespace.c:3591 [inline]
 __se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3568
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1449 [inline]
 free_pcp_prepare+0x812/0x900 mm/page_alloc.c:1499
 free_unref_page_prepare mm/page_alloc.c:3380 [inline]
 free_unref_page_list+0xb4/0x7b0 mm/page_alloc.c:3522
 release_pages+0x22c3/0x2540 mm/swap.c:1012
 tlb_batch_pages_flush mm/mmu_gather.c:58 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:255 [inline]
 tlb_flush_mmu+0x850/0xa70 mm/mmu_gather.c:262
 tlb_finish_mmu+0xcb/0x200 mm/mmu_gather.c:353
 exit_mmap+0x1cb/0x520 mm/mmap.c:3118
 __mmput+0x111/0x3a0 kernel/fork.c:1187
 exit_mm+0x1ef/0x2c0 kernel/exit.c:510
 do_exit+0x4e1/0x20a0 kernel/exit.c:782
 do_group_exit+0x23b/0x2f0 kernel/exit.c:925
 __do_sys_exit_group kernel/exit.c:936 [inline]
 __se_sys_exit_group kernel/exit.c:934 [inline]
 __x64_sys_exit_group+0x3b/0x40 kernel/exit.c:934
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
 ffff8880bff33e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880bff33f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8880bff33f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                               ^
 ffff8880bff34000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880bff34080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (10):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-upstream-fs 2022/09/26 06:55 upstream 105a36f3694e 0042f2b4 .config log report syz C KASAN: out-of-bounds Read in leaf_paste_entries
ci-upstream-kasan-gce-selinux-root 2021/12/13 19:20 upstream 2585cf9dfaad 49ca1f59 .config log report syz C KASAN: out-of-bounds Read in leaf_paste_entries
ci2-upstream-fs 2022/09/26 06:42 upstream 105a36f3694e 0042f2b4 .config log report info KASAN: out-of-bounds Read in leaf_paste_entries
ci-upstream-kasan-gce-selinux-root 2022/02/10 10:25 upstream f4bc5bbb5fef 0b33604d .config log report info KASAN: out-of-bounds Read in leaf_paste_entries
ci-upstream-kasan-gce-root 2022/01/31 18:17 upstream 26291c54e111 6b7c57fe .config log report info KASAN: out-of-bounds Read in leaf_paste_entries
ci-upstream-kasan-gce-selinux-root 2021/12/02 12:20 upstream 58e1100fdc59 61f86278 .config log report info KASAN: out-of-bounds Read in leaf_paste_entries
ci-upstream-kasan-gce-root 2021/11/18 19:34 upstream 42eb8fdac2fc 31a30fc0 .config log report info KASAN: out-of-bounds Read in leaf_paste_entries
ci-qemu-upstream-386 2021/11/12 06:32 upstream 5833291ab6de 75b04091 .config log report info KASAN: out-of-bounds Read in leaf_paste_entries
ci-upstream-linux-next-kasan-gce-root 2022/03/01 17:50 linux-next e6ada6df471f 45a13a73 .config log report info KASAN: out-of-bounds Read in leaf_paste_entries
ci-upstream-linux-next-kasan-gce-root 2022/02/06 06:34 linux-next ef6b35306dd8 a7dab638 .config log report info KASAN: out-of-bounds Read in leaf_paste_entries
* Struck through repros no longer work on HEAD.