================================================================== BUG: KASAN: slab-use-after-free in __up_read+0x330/0x3a0 kernel/locking/rwsem.c:1342 Read of size 8 at addr ffff88807b65c068 by task syz-executor.4/5172 CPU: 0 PID: 5172 Comm: syz-executor.4 Not tainted 6.5.0-rc3-syzkaller #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+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 __up_read+0x330/0x3a0 kernel/locking/rwsem.c:1342 iommufd_put_object drivers/iommu/iommufd/iommufd_private.h:148 [inline] iommufd_vfio_ioas+0x3cf/0x4e0 drivers/iommu/iommufd/vfio_compat.c:146 iommufd_fops_ioctl+0x27a/0x3b0 drivers/iommu/iommufd/main.c:377 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x12b/0x1a0 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7ff09967cae9 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:00007ff09a41b0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007ff09979c120 RCX: 00007ff09967cae9 RDX: 0000000020000080 RSI: 0000000000003b88 RDI: 0000000000000003 RBP: 00007ff0996c847a R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 000000000000000b R14: 00007ff09979c120 R15: 00007ffd11ca11e8 Allocated by task 5170: 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+0xa3/0xb0 mm/kasan/common.c:383 kasan_kmalloc include/linux/kasan.h:196 [inline] __do_kmalloc_node mm/slab_common.c:985 [inline] __kmalloc+0x5d/0x160 mm/slab_common.c:998 kmalloc include/linux/slab.h:586 [inline] kzalloc include/linux/slab.h:703 [inline] _iommufd_object_alloc+0x1b/0x140 drivers/iommu/iommufd/main.c:38 iommufd_ioas_alloc drivers/iommu/iommufd/ioas.c:27 [inline] iommufd_ioas_alloc_ioctl+0x9c/0x310 drivers/iommu/iommufd/ioas.c:46 iommufd_fops_ioctl+0x27a/0x3b0 drivers/iommu/iommufd/main.c:377 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x12b/0x1a0 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 5173: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x28/0x40 mm/kasan/generic.c:522 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x13f/0x190 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:162 [inline] __cache_free mm/slab.c:3370 [inline] __do_kmem_cache_free mm/slab.c:3557 [inline] __kmem_cache_free+0xbb/0x2c0 mm/slab.c:3564 iommufd_destroy+0xf5/0x140 drivers/iommu/iommufd/main.c:203 iommufd_fops_ioctl+0x27a/0x3b0 drivers/iommu/iommufd/main.c:377 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x12b/0x1a0 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff88807b65c000 which belongs to the cache kmalloc-cg-1k of size 1024 The buggy address is located 104 bytes inside of freed 1024-byte region [ffff88807b65c000, ffff88807b65c400) The buggy address belongs to the physical page: page:ffffea0001ed9700 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7b65c memcg:ffff888069608641 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0x2() raw: 00fff00000000200 ffff88800a84d800 ffffea0001a04f50 ffffea000077fbd0 raw: 0000000000000000 ffff88807b65c000 0000000100000002 ffff888069608641 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x3420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 4418, tgid 4417 (syz-executor.3), ts 67178753666, free_ts 67160033050 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x281/0x2f0 mm/page_alloc.c:1570 prep_new_page mm/page_alloc.c:1577 [inline] get_page_from_freelist+0xfcb/0x31e0 mm/page_alloc.c:3221 __alloc_pages+0x1d0/0x470 mm/page_alloc.c:4477 __alloc_pages_node include/linux/gfp.h:237 [inline] kmem_getpages mm/slab.c:1356 [inline] cache_grow_begin+0x7c/0x330 mm/slab.c:2550 cache_alloc_refill+0x286/0x350 mm/slab.c:2923 ____cache_alloc mm/slab.c:2999 [inline] ____cache_alloc mm/slab.c:2982 [inline] __do_cache_alloc mm/slab.c:3182 [inline] slab_alloc_node mm/slab.c:3230 [inline] __kmem_cache_alloc_node+0x383/0x3d0 mm/slab.c:3521 __do_kmalloc_node mm/slab_common.c:984 [inline] __kmalloc+0x4c/0x160 mm/slab_common.c:998 kmalloc include/linux/slab.h:586 [inline] kzalloc include/linux/slab.h:703 [inline] _iommufd_object_alloc+0x1b/0x140 drivers/iommu/iommufd/main.c:38 iommufd_ioas_alloc drivers/iommu/iommufd/ioas.c:27 [inline] iommufd_ioas_alloc_ioctl+0x9c/0x310 drivers/iommu/iommufd/ioas.c:46 iommufd_fops_ioctl+0x27a/0x3b0 drivers/iommu/iommufd/main.c:377 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x12b/0x1a0 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1161 [inline] free_unref_page_prepare+0x5aa/0xc40 mm/page_alloc.c:2348 free_unref_page+0x33/0x350 mm/page_alloc.c:2443 slab_destroy mm/slab.c:1608 [inline] slabs_destroy+0x85/0xc0 mm/slab.c:1628 cache_flusharray mm/slab.c:3341 [inline] ___cache_free+0x297/0x3b0 mm/slab.c:3404 qlink_free mm/kasan/quarantine.c:166 [inline] qlist_free_all+0x71/0x1a0 mm/kasan/quarantine.c:185 kasan_quarantine_reduce+0x17d/0x1b0 mm/kasan/quarantine.c:292 __kasan_slab_alloc+0x65/0x90 mm/kasan/common.c:305 kasan_slab_alloc include/linux/kasan.h:186 [inline] slab_post_alloc_hook mm/slab.h:762 [inline] slab_alloc_node mm/slab.c:3237 [inline] slab_alloc mm/slab.c:3246 [inline] __kmem_cache_alloc_lru mm/slab.c:3423 [inline] kmem_cache_alloc+0x1d6/0x3d0 mm/slab.c:3432 getname_flags.part.0+0x4a/0x430 fs/namei.c:140 do_sys_openat2+0xe8/0x170 fs/open.c:1401 do_sys_open fs/open.c:1422 [inline] __do_sys_openat fs/open.c:1438 [inline] __se_sys_openat fs/open.c:1433 [inline] __x64_sys_openat+0x134/0x1d0 fs/open.c:1433 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Memory state around the buggy address: ffff88807b65bf00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff88807b65bf80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff88807b65c000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807b65c080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807b65c100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================