================================================================== BUG: KASAN: slab-use-after-free in queue_cnt drivers/ptp/ptp_private.h:89 [inline] BUG: KASAN: slab-use-after-free in ptp_read+0x5e4/0x820 drivers/ptp/ptp_chardev.c:547 Read of size 4 at addr ffff888015f39004 by task syz-executor.0/10704 CPU: 0 PID: 10704 Comm: syz-executor.0 Not tainted 6.6.0-syzkaller-15156-g13d88ac54ddd #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023 Call Trace: __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:364 [inline] print_report+0x163/0x540 mm/kasan/report.c:475 kasan_report+0x142/0x170 mm/kasan/report.c:588 queue_cnt drivers/ptp/ptp_private.h:89 [inline] ptp_read+0x5e4/0x820 drivers/ptp/ptp_chardev.c:547 posix_clock_read+0x12f/0x190 kernel/time/posix-clock.c:51 vfs_read+0x289/0xb00 fs/read_write.c:468 ksys_read+0x1a0/0x2c0 fs/read_write.c:613 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x63/0x6b RIP: 0033:0x7ffa3a47cae9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 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 b0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffa3b1040c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 00007ffa3a59c050 RCX: 00007ffa3a47cae9 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003 RBP: 00007ffa3a4c847a R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 000000000000006e R14: 00007ffa3a59c050 R15: 00007ffce4e3a0b8 Allocated by task 10701: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4f/0x70 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:600 [inline] kzalloc include/linux/slab.h:721 [inline] ptp_open+0xd9/0x430 drivers/ptp/ptp_chardev.c:112 posix_clock_open+0x155/0x1f0 kernel/time/posix-clock.c:134 chrdev_open+0x5ab/0x630 fs/char_dev.c:414 do_dentry_open+0x8fd/0x1590 fs/open.c:948 do_open fs/namei.c:3622 [inline] path_openat+0x2845/0x3280 fs/namei.c:3779 do_filp_open+0x234/0x490 fs/namei.c:3809 do_sys_openat2+0x13e/0x1d0 fs/open.c:1440 do_sys_open fs/open.c:1455 [inline] __do_sys_openat fs/open.c:1471 [inline] __se_sys_openat fs/open.c:1466 [inline] __x64_sys_openat+0x247/0x290 fs/open.c:1466 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x63/0x6b Freed by task 10701: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4f/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x28/0x40 mm/kasan/generic.c:522 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236 kasan_slab_free include/linux/kasan.h:164 [inline] slab_free_hook mm/slub.c:1800 [inline] slab_free_freelist_hook mm/slub.c:1826 [inline] slab_free mm/slub.c:3809 [inline] __kmem_cache_free+0x263/0x3a0 mm/slub.c:3822 ptp_release+0x1ce/0x1e0 drivers/ptp/ptp_chardev.c:150 ptp_read+0x17f/0x820 drivers/ptp/ptp_chardev.c:589 posix_clock_read+0x12f/0x190 kernel/time/posix-clock.c:51 vfs_read+0x289/0xb00 fs/read_write.c:468 ksys_read+0x1a0/0x2c0 fs/read_write.c:613 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x63/0x6b Last potentially related work creation: kasan_save_stack+0x3f/0x60 mm/kasan/common.c:45 __kasan_record_aux_stack+0xad/0xc0 mm/kasan/generic.c:492 insert_work+0x3e/0x320 kernel/workqueue.c:1647 __queue_work+0xc06/0x1010 kernel/workqueue.c:1799 queue_work_on+0x14f/0x250 kernel/workqueue.c:1834 queue_work include/linux/workqueue.h:562 [inline] schedule_work include/linux/workqueue.h:623 [inline] f2fs_handle_critical_error+0x7cb/0x9d0 fs/f2fs/super.c:4179 f2fs_write_end_io+0x7da/0xb00 fs/f2fs/data.c:366 __submit_merged_bio+0x28e/0x6c0 fs/f2fs/data.c:589 __f2fs_submit_merged_write fs/f2fs/data.c:682 [inline] __submit_merged_write_cond fs/f2fs/data.c:704 [inline] f2fs_submit_merged_write_cond+0x28a/0x360 fs/f2fs/data.c:721 f2fs_write_cache_pages fs/f2fs/data.c:3296 [inline] __f2fs_write_data_pages fs/f2fs/data.c:3381 [inline] f2fs_write_data_pages+0x302e/0x3ab0 fs/f2fs/data.c:3408 do_writepages+0x3a6/0x670 mm/page-writeback.c:2553 filemap_fdatawrite_wbc+0x125/0x180 mm/filemap.c:387 __filemap_fdatawrite_range mm/filemap.c:420 [inline] __filemap_fdatawrite mm/filemap.c:426 [inline] filemap_fdatawrite+0x143/0x1b0 mm/filemap.c:431 f2fs_sync_dirty_inodes+0x337/0x840 fs/f2fs/checkpoint.c:1107 block_operations fs/f2fs/checkpoint.c:1240 [inline] f2fs_write_checkpoint+0xb6d/0x1fa0 fs/f2fs/checkpoint.c:1648 f2fs_issue_checkpoint+0x2e6/0x4d0 fs/f2fs/checkpoint.c:1855 f2fs_rename fs/f2fs/namei.c:1126 [inline] f2fs_rename2+0x23da/0x2890 fs/f2fs/namei.c:1332 vfs_rename+0xaba/0xde0 fs/namei.c:4844 do_renameat2+0xd5a/0x1390 fs/namei.c:4996 __do_sys_renameat2 fs/namei.c:5029 [inline] __se_sys_renameat2 fs/namei.c:5026 [inline] __x64_sys_renameat2+0xd2/0xe0 fs/namei.c:5026 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x63/0x6b The buggy address belongs to the object at ffff888015f38000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 4100 bytes inside of freed 8192-byte region [ffff888015f38000, ffff888015f3a000) The buggy address belongs to the physical page: page:ffffea000057ce00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x15f38 head:ffffea000057ce00 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0 ksm flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000840 ffff888012c42280 ffffea0000959000 0000000000000003 raw: 0000000000000000 0000000080020002 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 9387, tgid 9386 (syz-executor.3), ts 634041644314, free_ts 633925965288 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x1e6/0x210 mm/page_alloc.c:1537 prep_new_page mm/page_alloc.c:1544 [inline] get_page_from_freelist+0x339a/0x3530 mm/page_alloc.c:3312 __alloc_pages+0x255/0x670 mm/page_alloc.c:4568 alloc_pages_mpol+0x3de/0x640 mm/mempolicy.c:2133 alloc_slab_page+0x6a/0x160 mm/slub.c:1870 allocate_slab mm/slub.c:2017 [inline] new_slab+0x84/0x2f0 mm/slub.c:2070 ___slab_alloc+0xc85/0x1310 mm/slub.c:3223 __slab_alloc mm/slub.c:3322 [inline] __slab_alloc_node mm/slub.c:3375 [inline] slab_alloc_node mm/slub.c:3468 [inline] __kmem_cache_alloc_node+0x21d/0x300 mm/slub.c:3517 __do_kmalloc_node mm/slab_common.c:1006 [inline] __kmalloc+0xa8/0x230 mm/slab_common.c:1020 read_all_xattrs+0x12e/0x490 fs/f2fs/xattr.c:398 __f2fs_setxattr+0x21d/0x1280 fs/f2fs/xattr.c:653 f2fs_initxattrs+0xa3/0x110 fs/f2fs/xattr.c:145 security_inode_init_security+0x2a7/0x470 security/security.c:1668 f2fs_init_inode_metadata+0x87b/0x1180 fs/f2fs/dir.c:562 f2fs_add_inline_entry+0x3c1/0x720 fs/f2fs/inline.c:646 f2fs_add_dentry+0xba/0x1e0 fs/f2fs/dir.c:784 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1137 [inline] free_unref_page_prepare+0x92a/0xa50 mm/page_alloc.c:2347 free_unref_page+0x37/0x3f0 mm/page_alloc.c:2487 discard_slab mm/slub.c:2116 [inline] __unfreeze_partials+0x1dc/0x220 mm/slub.c:2655 put_cpu_partial+0x17b/0x250 mm/slub.c:2731 __slab_free+0x2b6/0x390 mm/slub.c:3679 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x75/0xe0 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x14b/0x160 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x23/0x70 mm/kasan/common.c:305 kasan_slab_alloc include/linux/kasan.h:188 [inline] slab_post_alloc_hook+0x6c/0x3c0 mm/slab.h:763 slab_alloc_node mm/slub.c:3478 [inline] __kmem_cache_alloc_node+0x1d0/0x300 mm/slub.c:3517 __do_kmalloc_node mm/slab_common.c:1006 [inline] __kmalloc+0xa8/0x230 mm/slab_common.c:1020 kmalloc_array include/linux/slab.h:637 [inline] memcg_list_lru_alloc+0x23b/0xd20 mm/list_lru.c:487 memcg_slab_pre_alloc_hook mm/slab.h:501 [inline] slab_pre_alloc_hook+0x2a5/0x300 mm/slab.h:715 slab_alloc_node mm/slub.c:3460 [inline] slab_alloc mm/slub.c:3486 [inline] __kmem_cache_alloc_lru mm/slub.c:3493 [inline] kmem_cache_alloc_lru+0x4e/0x2c0 mm/slub.c:3509 alloc_inode_sb include/linux/fs.h:2937 [inline] ext4_alloc_inode+0x2e/0x580 fs/ext4/super.c:1408 alloc_inode fs/inode.c:259 [inline] iget_locked+0x1cc/0x830 fs/inode.c:1314 Memory state around the buggy address: ffff888015f38f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888015f38f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888015f39000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888015f39080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888015f39100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================