================================================================== BUG: KASAN: slab-use-after-free in queue_cnt drivers/ptp/ptp_private.h:82 [inline] BUG: KASAN: slab-use-after-free in ptp_read+0x6d0/0x780 drivers/ptp/ptp_chardev.c:507 Read of size 4 at addr ffff888116c61004 by task syz-executor.0/1861 CPU: 1 PID: 1861 Comm: syz-executor.0 Not tainted 6.6.0-rc5-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x3d/0x60 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:82 [inline] ptp_read+0x6d0/0x780 drivers/ptp/ptp_chardev.c:507 posix_clock_read+0x112/0x180 kernel/time/posix-clock.c:51 vfs_read+0x161/0x870 fs/read_write.c:468 ksys_read+0xf6/0x1d0 fs/read_write.c:613 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0x80 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f1ea9855ae9 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:00007f1ea93d80c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 00007f1ea9974f80 RCX: 00007f1ea9855ae9 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003 RBP: 00007f1ea98a147a R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000006 R14: 00007f1ea9974f80 R15: 00007ffe55764bc8 Allocated by task 1861: 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:599 [inline] kzalloc include/linux/slab.h:720 [inline] ptp_open+0x69/0x230 drivers/ptp/ptp_chardev.c:110 posix_clock_open+0x15e/0x200 kernel/time/posix-clock.c:134 chrdev_open+0x21a/0x620 fs/char_dev.c:414 do_dentry_open+0x5db/0x11b0 fs/open.c:929 do_open fs/namei.c:3639 [inline] path_openat+0x18b8/0x27c0 fs/namei.c:3796 do_filp_open+0x1bc/0x400 fs/namei.c:3823 do_sys_openat2+0x12c/0x170 fs/open.c:1422 do_sys_open fs/open.c:1437 [inline] __do_sys_openat fs/open.c:1453 [inline] __se_sys_openat fs/open.c:1448 [inline] __x64_sys_openat+0x134/0x1d0 fs/open.c:1448 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0x80 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 1863: 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+0xba/0x330 mm/slub.c:3822 ptp_release+0x168/0x1e0 drivers/ptp/ptp_chardev.c:129 ptp_read+0xce/0x780 drivers/ptp/ptp_chardev.c:549 posix_clock_read+0x112/0x180 kernel/time/posix-clock.c:51 vfs_read+0x161/0x870 fs/read_write.c:468 ksys_read+0xf6/0x1d0 fs/read_write.c:613 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0x80 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff888116c60000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 4100 bytes inside of freed 8192-byte region [ffff888116c60000, ffff888116c62000) The buggy address belongs to the physical page: page:ffffea00045b1800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x116c60 head:ffffea00045b1800 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0x200000000000840(slab|head|node=0|zone=2) page_type: 0xffffffff() raw: 0200000000000840 ffff888100042280 dead000000000122 0000000000000000 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 1405, tgid 1405 (syz-execprog), ts 45007176006, free_ts 44930720796 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x27e/0x2f0 mm/page_alloc.c:1536 prep_new_page mm/page_alloc.c:1543 [inline] get_page_from_freelist+0xcd4/0x3060 mm/page_alloc.c:3170 __alloc_pages+0x1d0/0x470 mm/page_alloc.c:4426 alloc_slab_page mm/slub.c:1870 [inline] allocate_slab+0x24b/0x360 mm/slub.c:2017 new_slab mm/slub.c:2070 [inline] ___slab_alloc+0x8c2/0x10c0 mm/slub.c:3223 __slab_alloc.constprop.0+0x4d/0x90 mm/slub.c:3322 __slab_alloc_node mm/slub.c:3375 [inline] slab_alloc_node mm/slub.c:3468 [inline] __kmem_cache_alloc_node+0x13f/0x390 mm/slub.c:3517 kmalloc_trace+0x25/0xb0 mm/slab_common.c:1114 kmalloc include/linux/slab.h:599 [inline] kzalloc include/linux/slab.h:720 [inline] tomoyo_print_bprm security/tomoyo/audit.c:26 [inline] tomoyo_init_log+0xb57/0x1ee0 security/tomoyo/audit.c:264 tomoyo_supervisor+0x2a7/0xc40 security/tomoyo/common.c:2089 tomoyo_audit_env_log security/tomoyo/environ.c:36 [inline] tomoyo_env_perm+0x16c/0x1d0 security/tomoyo/environ.c:63 tomoyo_environ security/tomoyo/domain.c:672 [inline] tomoyo_find_next_domain+0xaf6/0x1db0 security/tomoyo/domain.c:878 tomoyo_bprm_check_security security/tomoyo/tomoyo.c:101 [inline] tomoyo_bprm_check_security+0x109/0x170 security/tomoyo/tomoyo.c:91 security_bprm_check+0x4f/0x70 security/security.c:1103 search_binary_handler fs/exec.c:1727 [inline] exec_binprm fs/exec.c:1781 [inline] bprm_execve fs/exec.c:1856 [inline] bprm_execve+0x5fe/0x1430 fs/exec.c:1812 do_execveat_common.isra.0+0x4bc/0x690 fs/exec.c:1964 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1136 [inline] free_unref_page_prepare+0x4f4/0xb80 mm/page_alloc.c:2312 free_unref_page+0x33/0x2a0 mm/page_alloc.c:2405 __unfreeze_partials+0x1f1/0x210 mm/slub.c:2655 qlink_free mm/kasan/quarantine.c:166 [inline] qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:185 kasan_quarantine_reduce+0x180/0x1b0 mm/kasan/quarantine.c:292 __kasan_slab_alloc+0x65/0x90 mm/kasan/common.c:305 kasan_slab_alloc include/linux/kasan.h:188 [inline] slab_post_alloc_hook mm/slab.h:762 [inline] slab_alloc_node mm/slub.c:3478 [inline] __kmem_cache_alloc_node+0x1a8/0x390 mm/slub.c:3517 kmalloc_trace+0x25/0xb0 mm/slab_common.c:1114 kmalloc include/linux/slab.h:599 [inline] tomoyo_print_header security/tomoyo/audit.c:156 [inline] tomoyo_init_log+0x198/0x1ee0 security/tomoyo/audit.c:255 tomoyo_supervisor+0x2a7/0xc40 security/tomoyo/common.c:2089 tomoyo_audit_path_log security/tomoyo/file.c:168 [inline] tomoyo_path_permission security/tomoyo/file.c:587 [inline] tomoyo_path_permission+0x23d/0x330 security/tomoyo/file.c:573 tomoyo_check_open_permission+0x28a/0x2b0 security/tomoyo/file.c:777 security_file_open+0x4f/0x80 security/security.c:2836 do_dentry_open+0x339/0x11b0 fs/open.c:916 do_open fs/namei.c:3639 [inline] path_openat+0x18b8/0x27c0 fs/namei.c:3796 do_filp_open+0x1bc/0x400 fs/namei.c:3823 Memory state around the buggy address: ffff888116c60f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888116c60f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888116c61000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888116c61080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888116c61100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================