ubi0: attaching mtd0 ubi0: scanning is finished ================================================================== BUG: KASAN: slab-use-after-free in notifier_chain_register+0x3ac/0x420 kernel/notifier.c:27 Read of size 4 at addr ffff888029aad8d8 by task syz-executor304/5832 CPU: 0 UID: 0 PID: 5832 Comm: syz-executor304 Not tainted 6.12.0-syzkaller-12113-gbcc8eda6d349 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xc3/0x620 mm/kasan/report.c:489 kasan_report+0xd9/0x110 mm/kasan/report.c:602 notifier_chain_register+0x3ac/0x420 kernel/notifier.c:27 __blocking_notifier_chain_register kernel/notifier.c:264 [inline] blocking_notifier_chain_register+0x76/0xd0 kernel/notifier.c:282 ubi_wl_init+0x1018/0x17b0 drivers/mtd/ubi/wl.c:1960 ubi_attach+0x1b92/0x4c00 drivers/mtd/ubi/attach.c:1605 ubi_attach_mtd_dev+0x158f/0x3590 drivers/mtd/ubi/build.c:1004 ctrl_cdev_ioctl+0x339/0x3d0 drivers/mtd/ubi/cdev.c:1043 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:906 [inline] __se_sys_ioctl fs/ioctl.c:892 [inline] __x64_sys_ioctl+0x190/0x200 fs/ioctl.c:892 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f53256e4c79 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 91 1a 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:00007f5324e57218 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f532576f468 RCX: 00007f53256e4c79 RDX: 0000000020000502 RSI: 0000000040186f40 RDI: 0000000000000005 RBP: 00007f532576f460 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f532573b6a4 R13: b635773f06ebbeee R14: 006c7274635f6962 R15: 6962752f7665642f Allocated by task 5826: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:377 [inline] __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:394 kmalloc_noprof include/linux/slab.h:901 [inline] kzalloc_noprof include/linux/slab.h:1037 [inline] ubi_attach_mtd_dev+0x3ce/0x3590 drivers/mtd/ubi/build.c:933 ctrl_cdev_ioctl+0x339/0x3d0 drivers/mtd/ubi/cdev.c:1043 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:906 [inline] __se_sys_ioctl fs/ioctl.c:892 [inline] __x64_sys_ioctl+0x190/0x200 fs/ioctl.c:892 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 5826: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:582 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x51/0x70 mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:233 [inline] slab_free_hook mm/slub.c:2338 [inline] slab_free mm/slub.c:4598 [inline] kfree+0x14f/0x4b0 mm/slub.c:4746 device_release+0xa1/0x240 drivers/base/core.c:2567 kobject_cleanup lib/kobject.c:689 [inline] kobject_release lib/kobject.c:720 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x1e4/0x5a0 lib/kobject.c:737 put_device+0x1f/0x30 drivers/base/core.c:3773 ubi_attach_mtd_dev+0xe25/0x3590 drivers/mtd/ubi/build.c:1076 ctrl_cdev_ioctl+0x339/0x3d0 drivers/mtd/ubi/cdev.c:1043 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:906 [inline] __se_sys_ioctl fs/ioctl.c:892 [inline] __x64_sys_ioctl+0x190/0x200 fs/ioctl.c:892 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff888029aac000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 6360 bytes inside of freed 8192-byte region [ffff888029aac000, ffff888029aae000) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x29aa8 head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000040 ffff88801b042280 dead000000000122 0000000000000000 raw: 0000000000000000 0000000080020002 00000001f5000000 0000000000000000 head: 00fff00000000040 ffff88801b042280 dead000000000122 0000000000000000 head: 0000000000000000 0000000080020002 00000001f5000000 0000000000000000 head: 00fff00000000003 ffffea0000a6aa01 ffffffffffffffff 0000000000000000 head: 0000000000000008 0000000000000000 00000000ffffffff 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 0x52820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 5826, tgid 5823 (syz-executor304), ts 46956066401, free_ts 46739507766 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x2d1/0x350 mm/page_alloc.c:1556 prep_new_page mm/page_alloc.c:1564 [inline] get_page_from_freelist+0xfce/0x2f80 mm/page_alloc.c:3474 __alloc_pages_noprof+0x223/0x25b0 mm/page_alloc.c:4751 alloc_pages_mpol_noprof+0x2c9/0x610 mm/mempolicy.c:2265 alloc_slab_page mm/slub.c:2408 [inline] allocate_slab mm/slub.c:2574 [inline] new_slab+0x2c9/0x410 mm/slub.c:2627 ___slab_alloc+0xdac/0x1870 mm/slub.c:3815 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3905 __slab_alloc_node mm/slub.c:3980 [inline] slab_alloc_node mm/slub.c:4141 [inline] __kmalloc_cache_noprof+0xfa/0x410 mm/slub.c:4309 kmalloc_noprof include/linux/slab.h:901 [inline] audit_log_d_path+0xce/0x1e0 kernel/audit.c:2149 dump_common_audit_data security/lsm_audit.c:250 [inline] common_lsm_audit+0xa6a/0x2250 security/lsm_audit.c:458 slow_avc_audit+0x17d/0x210 security/selinux/avc.c:773 avc_xperms_audit security/selinux/avc.c:419 [inline] avc_has_extended_perms+0x9a1/0xf70 security/selinux/avc.c:1083 ioctl_has_perm.constprop.0.isra.0+0x2ea/0x460 security/selinux/hooks.c:3691 selinux_file_ioctl+0x180/0x270 security/selinux/hooks.c:3739 security_file_ioctl+0xc6/0x240 security/security.c:2908 __do_sys_ioctl fs/ioctl.c:900 [inline] __se_sys_ioctl fs/ioctl.c:892 [inline] __x64_sys_ioctl+0xb7/0x200 fs/ioctl.c:892 page last free pid 5812 tgid 5812 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1127 [inline] free_unref_page+0x661/0x1080 mm/page_alloc.c:2657 __put_partials+0x14c/0x170 mm/slub.c:3142 qlink_free mm/kasan/quarantine.c:163 [inline] qlist_free_all+0x4e/0x120 mm/kasan/quarantine.c:179 kasan_quarantine_reduce+0x195/0x1e0 mm/kasan/quarantine.c:286 __kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:329 kasan_slab_alloc include/linux/kasan.h:250 [inline] slab_post_alloc_hook mm/slub.c:4104 [inline] slab_alloc_node mm/slub.c:4153 [inline] __do_kmalloc_node mm/slub.c:4282 [inline] __kmalloc_noprof+0x1cd/0x510 mm/slub.c:4295 kmalloc_noprof include/linux/slab.h:905 [inline] tomoyo_realpath_from_path+0xb9/0x720 security/tomoyo/realpath.c:251 tomoyo_mount_acl+0x66d/0x880 security/tomoyo/mount.c:141 tomoyo_mount_permission+0x16e/0x420 security/tomoyo/mount.c:237 security_sb_mount+0x9b/0x260 security/security.c:1564 path_mount+0x129/0x1f20 fs/namespace.c:3776 do_mount fs/namespace.c:3847 [inline] __do_sys_mount fs/namespace.c:4057 [inline] __se_sys_mount fs/namespace.c:4034 [inline] __x64_sys_mount+0x294/0x320 fs/namespace.c:4034 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Memory state around the buggy address: ffff888029aad780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888029aad800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888029aad880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888029aad900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888029aad980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================