================================================================== 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+0x7c4/0x830 drivers/ptp/ptp_chardev.c:547 Read of size 4 at addr ffff88801f0d9004 by task syz-executor361/5068 CPU: 1 PID: 5068 Comm: syz-executor361 Not tainted 6.6.0-syzkaller-06824-g8bc9e6515183 #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+0xd9/0x1b0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:364 [inline] print_report+0xc4/0x620 mm/kasan/report.c:475 kasan_report+0xda/0x110 mm/kasan/report.c:588 queue_cnt drivers/ptp/ptp_private.h:89 [inline] ptp_read+0x7c4/0x830 drivers/ptp/ptp_chardev.c:547 posix_clock_read+0x138/0x1b0 kernel/time/posix-clock.c:51 vfs_read+0x1ce/0x8f0 fs/read_write.c:468 ksys_read+0x12f/0x250 fs/read_write.c:613 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x3f/0x110 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x63/0x6b RIP: 0033:0x7fb2a2f56c39 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 c1 17 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:00007fb2a2f19238 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 00007fb2a2fe0308 RCX: 00007fb2a2f56c39 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003 RBP: 00007fb2a2fe0300 R08: 00007fb2a2f196c0 R09: 00007fb2a2f196c0 R10: 00007fb2a2f196c0 R11: 0000000000000246 R12: 7074702f7665642f R13: 0000000000000000 R14: 00007ffef1cac960 R15: 00007ffef1caca48 Allocated by task 5068: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:600 [inline] kzalloc include/linux/slab.h:721 [inline] ptp_open+0xe3/0x4f0 drivers/ptp/ptp_chardev.c:112 posix_clock_open+0x17e/0x240 kernel/time/posix-clock.c:134 chrdev_open+0x26d/0x6e0 fs/char_dev.c:414 do_dentry_open+0x8d4/0x18d0 fs/open.c:948 do_open fs/namei.c:3622 [inline] path_openat+0x1d4e/0x2c40 fs/namei.c:3779 do_filp_open+0x1de/0x430 fs/namei.c:3809 do_sys_openat2+0x176/0x1e0 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+0x175/0x210 fs/open.c:1466 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x3f/0x110 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x63/0x6b Freed by task 5069: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:522 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x15b/0x1b0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:164 [inline] slab_free_hook mm/slub.c:1800 [inline] slab_free_freelist_hook+0x114/0x1e0 mm/slub.c:1826 slab_free mm/slub.c:3809 [inline] __kmem_cache_free+0xb8/0x2d0 mm/slub.c:3822 ptp_release+0x204/0x2b0 drivers/ptp/ptp_chardev.c:150 ptp_read+0xf6/0x830 drivers/ptp/ptp_chardev.c:589 posix_clock_read+0x138/0x1b0 kernel/time/posix-clock.c:51 vfs_read+0x1ce/0x8f0 fs/read_write.c:468 ksys_read+0x12f/0x250 fs/read_write.c:613 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x3f/0x110 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x63/0x6b The buggy address belongs to the object at ffff88801f0d8000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 4100 bytes inside of freed 8192-byte region [ffff88801f0d8000, ffff88801f0da000) The buggy address belongs to the physical page: page:ffffea00007c3600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1f0d8 head:ffffea00007c3600 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000840 ffff888013042280 dead000000000100 dead000000000122 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 59, tgid 59 (kworker/u4:4), ts 12205615871, free_ts 0 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1536 prep_new_page mm/page_alloc.c:1543 [inline] get_page_from_freelist+0xee0/0x2f20 mm/page_alloc.c:3170 __alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4426 alloc_pages+0x1a9/0x270 mm/mempolicy.c:2303 alloc_slab_page mm/slub.c:1870 [inline] allocate_slab+0x251/0x380 mm/slub.c:2017 new_slab mm/slub.c:2070 [inline] ___slab_alloc+0x8c7/0x1580 mm/slub.c:3223 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3322 __slab_alloc_node mm/slub.c:3375 [inline] slab_alloc_node mm/slub.c:3468 [inline] __kmem_cache_alloc_node+0x131/0x330 mm/slub.c:3517 __do_kmalloc_node mm/slab_common.c:1006 [inline] __kmalloc_node+0x52/0x110 mm/slab_common.c:1014 kmalloc_node include/linux/slab.h:620 [inline] kvmalloc_node+0x6f/0x1a0 mm/util.c:607 kvzalloc_node include/linux/slab.h:742 [inline] sbitmap_init_node+0x1c8/0x680 lib/sbitmap.c:113 scsi_realloc_sdev_budget_map+0x4d4/0x620 drivers/scsi/scsi_scan.c:246 scsi_alloc_sdev+0x9a9/0xd10 drivers/scsi/scsi_scan.c:356 scsi_probe_and_add_lun+0x170d/0x27d0 drivers/scsi/scsi_scan.c:1189 __scsi_scan_target+0x255/0xef0 drivers/scsi/scsi_scan.c:1693 scsi_scan_channel drivers/scsi/scsi_scan.c:1781 [inline] scsi_scan_channel+0x149/0x1e0 drivers/scsi/scsi_scan.c:1757 page_owner free stack trace missing Memory state around the buggy address: ffff88801f0d8f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88801f0d8f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88801f0d9000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88801f0d9080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88801f0d9100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================