================================================================== BUG: KASAN: slab-use-after-free in iopt_area_length drivers/iommu/iommufd/io_pagetable.h:93 [inline] BUG: KASAN: slab-use-after-free in iopt_unmap_iova_range+0x5c7/0x5f0 drivers/iommu/iommufd/io_pagetable.c:497 Read of size 8 at addr ffff88802134f220 by task syz-executor.2/7487 CPU: 1 PID: 7487 Comm: syz-executor.2 Not tainted 6.4.0-rc7-syzkaller-00226-ga92b7d26c743 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106 print_address_description.constprop.0+0x2c/0x3c0 mm/kasan/report.c:351 print_report mm/kasan/report.c:462 [inline] kasan_report+0x11c/0x130 mm/kasan/report.c:572 iopt_area_length drivers/iommu/iommufd/io_pagetable.h:93 [inline] iopt_unmap_iova_range+0x5c7/0x5f0 drivers/iommu/iommufd/io_pagetable.c:497 iopt_unmap_all+0x27/0x50 drivers/iommu/iommufd/io_pagetable.c:555 iommufd_ioas_unmap+0x3d0/0x490 drivers/iommu/iommufd/ioas.c:300 iommufd_fops_ioctl+0x317/0x4b0 drivers/iommu/iommufd/main.c:337 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+0x197/0x210 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f93fd48c389 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 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 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f93fe179168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f93fd5ac120 RCX: 00007f93fd48c389 RDX: 00000000200001c0 RSI: 0000000000003b86 RDI: 0000000000000003 RBP: 00007f93fd4d7493 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f93fd6cfb1f R14: 00007f93fe179300 R15: 0000000000022000 Allocated by task 7470: kasan_save_stack+0x22/0x40 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 mm/kasan/common.c:333 [inline] __kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:559 [inline] kzalloc include/linux/slab.h:680 [inline] iopt_alloc_area_pages+0x94/0x560 drivers/iommu/iommufd/io_pagetable.c:234 iopt_map_pages drivers/iommu/iommufd/io_pagetable.c:339 [inline] iopt_map_user_pages+0x205/0x4e0 drivers/iommu/iommufd/io_pagetable.c:404 iommufd_ioas_map+0x329/0x5f0 drivers/iommu/iommufd/ioas.c:222 iommufd_fops_ioctl+0x317/0x4b0 drivers/iommu/iommufd/main.c:337 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+0x197/0x210 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 7471: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2e/0x40 mm/kasan/generic.c:521 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x160/0x1c0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:162 [inline] slab_free_hook mm/slub.c:1781 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1807 slab_free mm/slub.c:3786 [inline] __kmem_cache_free+0xaf/0x2d0 mm/slub.c:3799 iopt_abort_area drivers/iommu/iommufd/io_pagetable.c:292 [inline] iopt_unmap_iova_range+0x288/0x5f0 drivers/iommu/iommufd/io_pagetable.c:509 iopt_unmap_all+0x27/0x50 drivers/iommu/iommufd/io_pagetable.c:555 iommufd_ioas_unmap+0x3d0/0x490 drivers/iommu/iommufd/ioas.c:300 iommufd_fops_ioctl+0x317/0x4b0 drivers/iommu/iommufd/main.c:337 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+0x197/0x210 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Last potentially related work creation: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:491 kvfree_call_rcu+0x70/0xad0 kernel/rcu/tree.c:3332 fib_rule_put include/net/fib_rules.h:113 [inline] fib_rule_put include/net/fib_rules.h:110 [inline] fib_rules_cleanup_ops net/core/fib_rules.c:194 [inline] fib_rules_unregister+0x325/0x450 net/core/fib_rules.c:206 ip_fib_net_exit+0x212/0x310 net/ipv4/fib_frontend.c:1593 fib_net_exit_batch+0x53/0xa0 net/ipv4/fib_frontend.c:1640 ops_exit_list+0x125/0x170 net/core/net_namespace.c:175 cleanup_net+0x4ee/0xb10 net/core/net_namespace.c:614 process_one_work+0x99a/0x15e0 kernel/workqueue.c:2408 worker_thread+0x67d/0x10c0 kernel/workqueue.c:2555 kthread+0x344/0x440 kernel/kthread.c:379 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 Second to last potentially related work creation: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:491 kvfree_call_rcu+0x70/0xad0 kernel/rcu/tree.c:3332 fib_rule_put include/net/fib_rules.h:113 [inline] fib_rule_put include/net/fib_rules.h:110 [inline] fib_rules_cleanup_ops net/core/fib_rules.c:194 [inline] fib_rules_unregister+0x325/0x450 net/core/fib_rules.c:206 ip_fib_net_exit+0x212/0x310 net/ipv4/fib_frontend.c:1593 fib_net_exit_batch+0x53/0xa0 net/ipv4/fib_frontend.c:1640 ops_exit_list+0x125/0x170 net/core/net_namespace.c:175 setup_net+0x7fb/0xc50 net/core/net_namespace.c:362 copy_net_ns+0x4ee/0x8e0 net/core/net_namespace.c:491 create_new_namespaces+0x3f6/0xb20 kernel/nsproxy.c:110 copy_namespaces+0x410/0x500 kernel/nsproxy.c:179 copy_process+0x322c/0x75c0 kernel/fork.c:2510 kernel_clone+0xeb/0x890 kernel/fork.c:2915 __do_sys_clone3+0x1cd/0x240 kernel/fork.c:3216 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff88802134f200 which belongs to the cache kmalloc-cg-192 of size 192 The buggy address is located 32 bytes inside of freed 192-byte region [ffff88802134f200, ffff88802134f2c0) The buggy address belongs to the physical page: page:ffffea000084d3c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2134f memcg:ffff888019318d01 anon flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000200 ffff88801244ddc0 ffffea0001869700 dead000000000005 raw: 0000000000000000 0000000080100010 00000001ffffffff ffff888019318d01 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 5329, tgid 5325 (syz-executor.0), ts 208561164719, free_ts 206074654689 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2db/0x350 mm/page_alloc.c:1731 prep_new_page mm/page_alloc.c:1738 [inline] get_page_from_freelist+0xf41/0x2c00 mm/page_alloc.c:3502 __alloc_pages+0x1cb/0x4a0 mm/page_alloc.c:4768 alloc_pages+0x1aa/0x270 mm/mempolicy.c:2279 alloc_slab_page mm/slub.c:1851 [inline] allocate_slab+0x25f/0x390 mm/slub.c:1998 new_slab mm/slub.c:2051 [inline] ___slab_alloc+0xa91/0x1400 mm/slub.c:3192 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3291 __slab_alloc_node mm/slub.c:3344 [inline] slab_alloc_node mm/slub.c:3441 [inline] __kmem_cache_alloc_node+0x136/0x320 mm/slub.c:3490 __do_kmalloc_node mm/slab_common.c:965 [inline] __kmalloc+0x4e/0x190 mm/slab_common.c:979 kmalloc include/linux/slab.h:563 [inline] kzalloc include/linux/slab.h:680 [inline] __register_sysctl_table+0x117/0x14e0 fs/proc/proc_sysctl.c:1376 ip6_frags_ns_sysctl_register net/ipv6/reassembly.c:473 [inline] ipv6_frags_init_net net/ipv6/reassembly.c:542 [inline] ipv6_frags_init_net+0x21a/0x350 net/ipv6/reassembly.c:530 ops_init+0xb9/0x6b0 net/core/net_namespace.c:136 setup_net+0x5d1/0xc50 net/core/net_namespace.c:339 copy_net_ns+0x4ee/0x8e0 net/core/net_namespace.c:491 create_new_namespaces+0x3f6/0xb20 kernel/nsproxy.c:110 unshare_nsproxy_namespaces+0xc1/0x1f0 kernel/nsproxy.c:228 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1302 [inline] free_unref_page_prepare+0x62e/0xcb0 mm/page_alloc.c:2564 free_unref_page+0x33/0x370 mm/page_alloc.c:2659 qlink_free mm/kasan/quarantine.c:166 [inline] qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:185 kasan_quarantine_reduce+0x195/0x220 mm/kasan/quarantine.c:292 __kasan_slab_alloc+0x63/0x90 mm/kasan/common.c:305 kasan_slab_alloc include/linux/kasan.h:186 [inline] slab_post_alloc_hook mm/slab.h:711 [inline] slab_alloc_node mm/slub.c:3451 [inline] __kmem_cache_alloc_node+0x17c/0x320 mm/slub.c:3490 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1057 kmalloc include/linux/slab.h:559 [inline] gro_cells_destroy net/core/gro_cells.c:125 [inline] gro_cells_destroy+0xbc/0x4c0 net/core/gro_cells.c:105 ip6gre_dev_free+0x19/0x60 net/ipv6/ip6_gre.c:1428 netdev_run_todo+0x6bf/0x1100 net/core/dev.c:10394 ip6gre_exit_batch_net+0x3ef/0x580 net/ipv6/ip6_gre.c:1643 ops_exit_list+0x125/0x170 net/core/net_namespace.c:175 cleanup_net+0x4ee/0xb10 net/core/net_namespace.c:614 process_one_work+0x99a/0x15e0 kernel/workqueue.c:2408 worker_thread+0x67d/0x10c0 kernel/workqueue.c:2555 kthread+0x344/0x440 kernel/kthread.c:379 Memory state around the buggy address: ffff88802134f100: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88802134f180: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc >ffff88802134f200: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88802134f280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff88802134f300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ==================================================================