syzbot


KASAN: use-after-free Read in ext4_ext_insert_extent

Status: moderation: reported on 2025/05/23 08:48
Subsystems: ext4
[Documentation on labels]
Reported-by: syzbot+4b4b3387aef1a16357f4@syzkaller.appspotmail.com
First crash: 5d19h, last: 5d15h
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Read in ext4_ext_insert_extent 1 384d 384d 0/3 auto-obsoleted due to no activity on 2024/08/13 04:16
android-5-10 KASAN: use-after-free Read in ext4_ext_insert_extent syz 2 56d 71d 0/2 premoderation: reported syz repro on 2025/03/14 06:10
upstream KASAN: slab-use-after-free Read in ext4_ext_insert_extent ext4 1 560d 556d 0/28 auto-obsoleted due to no activity on 2024/02/09 07:34

Sample crash report:
EXT4-fs (loop1): mounted filesystem 00000000-0000-0000-0000-000000000000 r/w without journal. Quota mode: writeback.
==================================================================
BUG: KASAN: use-after-free in ext4_ext_insert_extent+0x41b6/0x4af0 fs/ext4/extents.c:2084
Read of size 4 at addr ffff88802f03fc18 by task syz.1.45/6218

CPU: 0 UID: 0 PID: 6218 Comm: syz.1.45 Not tainted 6.15.0-rc7-syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:408 [inline]
 print_report+0xb4/0x290 mm/kasan/report.c:521
 kasan_report+0x118/0x150 mm/kasan/report.c:634
 ext4_ext_insert_extent+0x41b6/0x4af0 fs/ext4/extents.c:2084
 ext4_ext_map_blocks+0x179c/0x67c0 fs/ext4/extents.c:4400
 ext4_map_create_blocks fs/ext4/inode.c:520 [inline]
 ext4_map_blocks+0x807/0x1740 fs/ext4/inode.c:706
 _ext4_get_block+0x200/0x4c0 fs/ext4/inode.c:785
 ext4_get_block_unwritten+0x2e/0x100 fs/ext4/inode.c:818
 ext4_block_write_begin+0x546/0x1290 fs/ext4/inode.c:1067
 ext4_write_begin+0x6f6/0x12c0 fs/ext4/ext4_jbd2.h:-1
 ext4_da_write_begin+0x33a/0xa60 fs/ext4/inode.c:2932
 generic_perform_write+0x2c4/0x910 mm/filemap.c:4103
 ext4_buffered_write_iter+0xce/0x3a0 fs/ext4/file.c:299
 ext4_file_write_iter+0x298/0x1bc0 fs/ext4/file.c:-1
 new_sync_write fs/read_write.c:591 [inline]
 vfs_write+0x54b/0xa90 fs/read_write.c:684
 ksys_pwrite64 fs/read_write.c:791 [inline]
 __do_sys_pwrite64 fs/read_write.c:799 [inline]
 __se_sys_pwrite64 fs/read_write.c:796 [inline]
 __x64_sys_pwrite64+0x193/0x220 fs/read_write.c:796
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f7dce18e969
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f7dcf009038 EFLAGS: 00000246 ORIG_RAX: 0000000000000012
RAX: ffffffffffffffda RBX: 00007f7dce3b5fa0 RCX: 00007f7dce18e969
RDX: 000000000000fdef RSI: 0000200000000140 RDI: 0000000000000006
RBP: 00007f7dce210ab1 R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000fecc R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f7dce3b5fa0 R15: 00007ffcb3563038
 </TASK>

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffffffffffffffff pfn:0x2f03f
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 dead000000000100 dead000000000122 0000000000000000
raw: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5817, tgid 5817 (syz-executor), ts 95095170102, free_ts 103963527378
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1d8/0x230 mm/page_alloc.c:1714
 prep_new_page mm/page_alloc.c:1722 [inline]
 get_page_from_freelist+0x21c7/0x22a0 mm/page_alloc.c:3684
 __alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:4966
 alloc_pages_mpol+0x232/0x4a0 mm/mempolicy.c:2301
 alloc_slab_page mm/slub.c:2450 [inline]
 allocate_slab+0x8a/0x3b0 mm/slub.c:2618
 new_slab mm/slub.c:2672 [inline]
 ___slab_alloc+0xbfc/0x1480 mm/slub.c:3858
 __slab_alloc mm/slub.c:3948 [inline]
 __slab_alloc_node mm/slub.c:4023 [inline]
 slab_alloc_node mm/slub.c:4184 [inline]
 kmem_cache_alloc_node_noprof+0x280/0x3c0 mm/slub.c:4248
 kmalloc_reserve+0xbd/0x290 net/core/skbuff.c:577
 __alloc_skb+0x142/0x2d0 net/core/skbuff.c:668
 alloc_skb include/linux/skbuff.h:1340 [inline]
 nlmsg_new include/net/netlink.h:1019 [inline]
 rtmsg_fib+0xea/0x4c0 net/ipv4/fib_semantics.c:552
 fib_table_insert+0xd64/0x1b50 net/ipv4/fib_trie.c:1380
 fib_magic+0x2c4/0x390 net/ipv4/fib_frontend.c:1133
 fib_add_ifaddr+0x3fb/0x5f0 net/ipv4/fib_frontend.c:1177
 fib_netdev_event+0x382/0x490 net/ipv4/fib_frontend.c:1515
 notifier_call_chain+0x1b3/0x3e0 kernel/notifier.c:85
 call_netdevice_notifiers_extack net/core/dev.c:2214 [inline]
 call_netdevice_notifiers net/core/dev.c:2228 [inline]
 __dev_notify_flags+0x18d/0x2e0 net/core/dev.c:-1
page last free pid 6056 tgid 6056 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1258 [inline]
 __free_frozen_pages+0xb05/0xcd0 mm/page_alloc.c:2721
 __slab_free+0x326/0x400 mm/slub.c:4553
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x9a/0x140 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x148/0x160 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x22/0x80 mm/kasan/common.c:329
 kasan_slab_alloc include/linux/kasan.h:250 [inline]
 slab_post_alloc_hook mm/slub.c:4147 [inline]
 slab_alloc_node mm/slub.c:4196 [inline]
 kmem_cache_alloc_noprof+0x1c1/0x3c0 mm/slub.c:4203
 mt_alloc_one lib/maple_tree.c:176 [inline]
 mas_alloc_nodes+0x2e9/0x8e0 lib/maple_tree.c:1249
 mas_node_count_gfp lib/maple_tree.c:1331 [inline]
 mas_preallocate+0x542/0x8b0 lib/maple_tree.c:5501
 vma_iter_prealloc mm/vma.h:409 [inline]
 __split_vma+0x315/0x9b0 mm/vma.c:490
 split_vma mm/vma.c:553 [inline]
 vma_modify+0x327/0x460 mm/vma.c:1587
 vma_modify_flags+0x1e8/0x230 mm/vma.c:1605
 mprotect_fixup+0x400/0x9b0 mm/mprotect.c:658
 do_mprotect_pkey+0x8cd/0xce0 mm/mprotect.c:832
 __do_sys_mprotect mm/mprotect.c:853 [inline]
 __se_sys_mprotect mm/mprotect.c:850 [inline]
 __x64_sys_mprotect+0x80/0x90 mm/mprotect.c:850
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xf6/0x210 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff88802f03fb00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88802f03fb80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88802f03fc00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                            ^
 ffff88802f03fc80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88802f03fd00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/05/19 08:38 upstream a5806cd506af f41472b0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: use-after-free Read in ext4_ext_insert_extent
2025/05/19 12:21 upstream a5806cd506af b84f0537 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ext4_ext_insert_extent
* Struck through repros no longer work on HEAD.