syzbot


KASAN: slab-use-after-free Read in f2fs_filemap_fault

Status: fixed on 2024/04/10 03:59
Subsystems: f2fs
[Documentation on labels]
Reported-by: syzbot+763afad57075d3f862f2@syzkaller.appspotmail.com
Fix commit: eb70d5a6c932 f2fs: fix to avoid use-after-free issue in f2fs_filemap_fault
First crash: 100d, last: 18d
Cause bisection: introduced by (bisect log) [merge ignored commit]:
commit bf9ca811bbadd7d853469d58284ed87906cc9321
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date: Fri Jan 12 21:52:21 2024 +0000

  Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma

Crash: KASAN: slab-use-after-free Read in f2fs_filemap_fault (log)
Repro: C syz .config
  
Discussions (4)
Title Replies (including bot) Last reply
[PATCH 6.8 604/715] f2fs: fix to avoid use-after-free issue in f2fs_filemap_fault 1 (1) 2024/03/24 22:33
[PATCH] f2fs: fix to avoid use-after-free issue in f2fs_filemap_fault 3 (3) 2024/03/14 16:20
[syzbot] [f2fs?] KASAN: slab-use-after-free Read in f2fs_filemap_fault 2 (5) 2024/03/13 14:50
[syzbot] Monthly f2fs report (Feb 2024) 0 (1) 2024/02/15 13:28
Last patch testing requests (2)
Created Duration User Patch Repo Result
2024/03/13 14:32 17m chao@kernel.org git://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git wip OK log
2024/01/15 12:05 1h31m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master OK log

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in f2fs_filemap_fault+0xd1/0x2c0 fs/f2fs/file.c:49
Read of size 8 at addr ffff88807bb22680 by task syz-executor184/5058

CPU: 0 PID: 5058 Comm: syz-executor184 Not tainted 6.7.0-syzkaller-09928-g052d534373b7 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x163/0x540 mm/kasan/report.c:488
 kasan_report+0x142/0x170 mm/kasan/report.c:601
 f2fs_filemap_fault+0xd1/0x2c0 fs/f2fs/file.c:49
 __do_fault+0x131/0x450 mm/memory.c:4376
 do_shared_fault mm/memory.c:4798 [inline]
 do_fault mm/memory.c:4872 [inline]
 do_pte_missing mm/memory.c:3745 [inline]
 handle_pte_fault mm/memory.c:5144 [inline]
 __handle_mm_fault+0x23b7/0x72b0 mm/memory.c:5285
 handle_mm_fault+0x27e/0x770 mm/memory.c:5450
 do_user_addr_fault arch/x86/mm/fault.c:1364 [inline]
 handle_page_fault arch/x86/mm/fault.c:1507 [inline]
 exc_page_fault+0x456/0x870 arch/x86/mm/fault.c:1563
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570
RIP: 0033:0x7f808e742b50
Code: 20 bf 02 00 00 00 e8 9f 24 04 00 48 83 f8 ff 0f 84 08 fa ff ff 48 89 05 e6 65 0c 00 e9 fc f9 ff ff 66 0f 1f 84 00 00 00 00 00 <c7> 04 25 40 00 00 20 66 32 66 73 c6 04 25 44 00 00 20 00 e9 0f fa
RSP: 002b:00007f808e735170 EFLAGS: 00010246

RAX: 0000000000000000 RBX: 00007f808e80b6e8 RCX: 00007f808e784fe9
RDX: 86d0f56bab720225 RSI: 0000000000000000 RDI: 00007f808e7355a0
RBP: 00007f808e80b6e0 R08: 0000000000000000 R09: 00007f808e7356c0
R10: 00007f808e80b6e0 R11: 0000000000000246 R12: 00007f808e80b6ec
R13: 0000000000000000 R14: 00007fff41e6fc30 R15: 00007fff41e6fd18
 </TASK>

Allocated by task 5058:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x70 mm/kasan/common.c:68
 unpoison_slab_object mm/kasan/common.c:314 [inline]
 __kasan_slab_alloc+0x66/0x70 mm/kasan/common.c:340
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3813 [inline]
 slab_alloc_node mm/slub.c:3860 [inline]
 kmem_cache_alloc+0x16f/0x340 mm/slub.c:3867
 vm_area_alloc+0x24/0x1d0 kernel/fork.c:465
 mmap_region+0xbd8/0x1f90 mm/mmap.c:2804
 do_mmap+0x76b/0xde0 mm/mmap.c:1379
 vm_mmap_pgoff+0x1e2/0x420 mm/util.c:556
 ksys_mmap_pgoff+0x4ff/0x6d0 mm/mmap.c:1425
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

Freed by task 5064:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x70 mm/kasan/common.c:68
 kasan_save_free_info+0x4e/0x60 mm/kasan/generic.c:634
 poison_slab_object+0xa6/0xe0 mm/kasan/common.c:241
 __kasan_slab_free+0x34/0x60 mm/kasan/common.c:257
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2121 [inline]
 slab_free mm/slub.c:4299 [inline]
 kmem_cache_free+0x102/0x2a0 mm/slub.c:4363
 rcu_do_batch kernel/rcu/tree.c:2158 [inline]
 rcu_core+0xad8/0x17c0 kernel/rcu/tree.c:2433
 __do_softirq+0x2b8/0x939 kernel/softirq.c:553

Last potentially related work creation:
 kasan_save_stack+0x3f/0x60 mm/kasan/common.c:47
 __kasan_record_aux_stack+0xae/0x100 mm/kasan/generic.c:580
 __call_rcu_common kernel/rcu/tree.c:2683 [inline]
 call_rcu+0x167/0xa80 kernel/rcu/tree.c:2797
 remove_vma mm/mmap.c:148 [inline]
 remove_mt mm/mmap.c:2283 [inline]
 do_vmi_align_munmap+0x159d/0x1930 mm/mmap.c:2629
 do_vmi_munmap+0x24d/0x2d0 mm/mmap.c:2693
 mmap_region+0x677/0x1f90 mm/mmap.c:2744
 do_mmap+0x76b/0xde0 mm/mmap.c:1379
 vm_mmap_pgoff+0x1e2/0x420 mm/util.c:556
 ksys_mmap_pgoff+0x4ff/0x6d0 mm/mmap.c:1425
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

The buggy address belongs to the object at ffff88807bb22660
 which belongs to the cache vm_area_struct of size 192
The buggy address is located 32 bytes inside of
 freed 192-byte region [ffff88807bb22660, ffff88807bb22720)

The buggy address belongs to the physical page:
page:ffffea0001eec880 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7bb22
flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000800 ffff8880142a1b40 dead000000000122 0000000000000000
raw: 0000000000000000 00000000800f000f 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 5039, tgid 5039 (sshd), ts 50202976366, free_ts 44674399535
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x1e6/0x210 mm/page_alloc.c:1533
 prep_new_page mm/page_alloc.c:1540 [inline]
 get_page_from_freelist+0x33ea/0x3570 mm/page_alloc.c:3311
 __alloc_pages+0x255/0x680 mm/page_alloc.c:4567
 __alloc_pages_node include/linux/gfp.h:238 [inline]
 alloc_pages_node include/linux/gfp.h:261 [inline]
 alloc_slab_page+0x5f/0x160 mm/slub.c:2190
 allocate_slab mm/slub.c:2354 [inline]
 new_slab+0x84/0x2f0 mm/slub.c:2407
 ___slab_alloc+0xd17/0x13d0 mm/slub.c:3540
 __slab_alloc mm/slub.c:3625 [inline]
 __slab_alloc_node mm/slub.c:3678 [inline]
 slab_alloc_node mm/slub.c:3850 [inline]
 kmem_cache_alloc+0x249/0x340 mm/slub.c:3867
 vm_area_dup+0x27/0x280 kernel/fork.c:480
 dup_mmap kernel/fork.c:695 [inline]
 dup_mm kernel/fork.c:1685 [inline]
 copy_mm+0xd90/0x21b0 kernel/fork.c:1734
 copy_process+0x1d6f/0x3fb0 kernel/fork.c:2496
 kernel_clone+0x222/0x840 kernel/fork.c:2901
 __do_sys_clone kernel/fork.c:3044 [inline]
 __se_sys_clone kernel/fork.c:3028 [inline]
 __x64_sys_clone+0x258/0x2a0 kernel/fork.c:3028
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b
page last free pid 5037 tgid 5037 stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1140 [inline]
 free_unref_page_prepare+0x959/0xa80 mm/page_alloc.c:2346
 free_unref_page+0x37/0x3f0 mm/page_alloc.c:2486
 pipe_buf_release include/linux/pipe_fs_i.h:219 [inline]
 pipe_update_tail fs/pipe.c:234 [inline]
 pipe_read+0x6ee/0x13e0 fs/pipe.c:354
 call_read_iter include/linux/fs.h:2079 [inline]
 new_sync_read fs/read_write.c:395 [inline]
 vfs_read+0x662/0x900 fs/read_write.c:476
 ksys_read+0x1a0/0x2c0 fs/read_write.c:619
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

Memory state around the buggy address:
 ffff88807bb22580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88807bb22600: 00 00 fc fc fc fc fc fc fc fc fc fc fa fb fb fb
>ffff88807bb22680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88807bb22700: fb fb fb fb fc fc fc fc fc fc fc fc fc fc 00 00
 ffff88807bb22780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (40):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/01/15 01:00 upstream 052d534373b7 551587c1 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/04/06 00:21 upstream fe46a7dd189e 18ea8213 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/03/10 06:13 upstream 09e5c48fea17 6ee49f2e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/03/07 09:06 upstream 67be068d31d4 f39a7eed .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/03/05 07:28 upstream 90d35da658da 5fc53669 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/03/04 02:41 upstream 58c806d867bf 25905f5d .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/03/03 03:46 upstream 5ad3cb0ed525 25905f5d .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/03/03 00:13 upstream 5ad3cb0ed525 25905f5d .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/03/01 10:08 upstream 87adedeba51a 352ab904 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/29 23:26 upstream 805d849d7c3c 352ab904 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/29 15:09 upstream 805d849d7c3c 352ab904 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/29 10:48 upstream e326df53af00 352ab904 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/29 09:36 upstream e326df53af00 352ab904 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/28 17:01 upstream cf1182944c7c 55d6f11d .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/27 12:15 upstream 45ec2f5f6ed3 05e69c83 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/26 16:48 upstream d206a76d7d27 da36a36b .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/24 18:19 upstream 603c04e27c3e 8d446f15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/24 12:45 upstream 603c04e27c3e 8d446f15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/22 21:10 upstream 1c892cdd8fe0 8d446f15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/22 14:29 upstream 39133352cbed 345111b5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/22 14:03 upstream 39133352cbed 345111b5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/20 20:16 upstream b401b621758e 3af7dd65 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/20 08:28 upstream b401b621758e 3af7dd65 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/20 02:38 upstream b401b621758e 3af7dd65 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/19 21:19 upstream b401b621758e 3af7dd65 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/19 03:59 upstream b401b621758e 578f7538 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/18 21:08 upstream c02197fc9076 578f7538 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/17 09:54 upstream c1ca10ceffbb 578f7538 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/08 20:49 upstream 047371968ffc 7f07e9b0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/08 18:20 upstream 047371968ffc 7f07e9b0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/06 13:28 upstream 99bd3cb0d12e 6404acf9 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/06 07:44 upstream 54be6c6c5ae8 6404acf9 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/01 10:49 upstream 6764c317b6bb 373b66cd .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/02/01 10:43 upstream 6764c317b6bb 373b66cd .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/01/29 23:30 upstream 41bccc98fb79 991a98f4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/01/29 14:47 upstream 41bccc98fb79 991a98f4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/01/23 23:31 upstream 7ed2632ec7d7 1e153dc8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/01/17 12:34 upstream 052d534373b7 2a7bcc7f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/01/16 07:53 upstream 052d534373b7 2a7bcc7f .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
2024/01/15 00:18 upstream 052d534373b7 551587c1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in f2fs_filemap_fault
* Struck through repros no longer work on HEAD.