ubi0: attaching mtd0 ubi0: scanning is finished ================================================================== BUG: KASAN: slab-out-of-bounds in notifier_chain_register+0x528/0x61a kernel/notifier.c:27 Read of size 4 at addr ff6000002ecf98e0 by task syz.1.6480/23478 CPU: 1 UID: 0 PID: 23478 Comm: syz.1.6480 Not tainted 6.13.0-rc3-syzkaller-g6f6ecce59d99 #0 Hardware name: riscv-virtio,qemu (DT) Call Trace: [] dump_backtrace+0x2e/0x3c arch/riscv/kernel/stacktrace.c:132 [] show_stack+0x30/0x3c arch/riscv/kernel/stacktrace.c:138 [] __dump_stack lib/dump_stack.c:94 [inline] [] dump_stack_lvl+0x12e/0x1a6 lib/dump_stack.c:120 [] print_address_description mm/kasan/report.c:378 [inline] [] print_report+0x28e/0x5aa mm/kasan/report.c:489 [] kasan_report+0xec/0x118 mm/kasan/report.c:602 [] __asan_report_load4_noabort+0x12/0x1a mm/kasan/report_generic.c:380 [] notifier_chain_register+0x528/0x61a kernel/notifier.c:27 [] __blocking_notifier_chain_register kernel/notifier.c:264 [inline] [] blocking_notifier_chain_register+0x80/0xc6 kernel/notifier.c:282 [] register_reboot_notifier+0x22/0x2c kernel/reboot.c:118 [] ubi_wl_init+0xd0a/0x15c2 drivers/mtd/ubi/wl.c:1960 [] ubi_attach+0x15da/0x4f90 drivers/mtd/ubi/attach.c:1605 [] ubi_attach_mtd_dev+0x14d8/0x3646 drivers/mtd/ubi/build.c:1004 [] ctrl_cdev_ioctl+0x496/0x764 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] [] __riscv_sys_ioctl+0x18e/0x1e2 fs/ioctl.c:892 [] syscall_handler+0x94/0x118 arch/riscv/include/asm/syscall.h:90 [] do_trap_ecall_u+0x1aa/0x216 arch/riscv/kernel/traps.c:331 [] handle_exception+0x146/0x152 arch/riscv/kernel/entry.S:197 Allocated by task 23339: stack_trace_save+0xa0/0xd2 kernel/stacktrace.c:122 kasan_save_stack+0x3e/0x6a mm/kasan/common.c:47 kasan_save_track+0x16/0x28 mm/kasan/common.c:68 kasan_save_alloc_info+0x30/0x3e mm/kasan/generic.c:568 poison_kmalloc_redzone mm/kasan/common.c:377 [inline] __kasan_kmalloc+0xa0/0xa6 mm/kasan/common.c:394 kasan_kmalloc include/linux/kasan.h:260 [inline] __do_kmalloc_node mm/slub.c:4298 [inline] __kmalloc_noprof+0x258/0x5ba mm/slub.c:4310 kmalloc_noprof include/linux/slab.h:905 [inline] tomoyo_realpath_from_path+0xb8/0x64a security/tomoyo/realpath.c:251 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_check_open_permission+0x2fe/0x3d6 security/tomoyo/file.c:771 tomoyo_file_open security/tomoyo/tomoyo.c:334 [inline] tomoyo_file_open+0xa0/0xc4 security/tomoyo/tomoyo.c:328 security_file_open+0xa8/0x250 security/security.c:3105 do_dentry_open+0x4de/0x1946 fs/open.c:928 vfs_open+0xbe/0x37c fs/open.c:1075 do_open fs/namei.c:3828 [inline] path_openat+0x1b70/0x28c2 fs/namei.c:3987 do_filp_open+0x19c/0x35c fs/namei.c:4014 do_sys_openat2+0x174/0x1ca fs/open.c:1402 do_sys_open fs/open.c:1417 [inline] __do_sys_openat fs/open.c:1433 [inline] __se_sys_openat fs/open.c:1428 [inline] __riscv_sys_openat+0x178/0x1fe fs/open.c:1428 syscall_handler+0x94/0x118 arch/riscv/include/asm/syscall.h:90 do_trap_ecall_u+0x1aa/0x216 arch/riscv/kernel/traps.c:331 handle_exception+0x146/0x152 arch/riscv/kernel/entry.S:197 Freed by task 23339: stack_trace_save+0xa0/0xd2 kernel/stacktrace.c:122 kasan_save_stack+0x3e/0x6a mm/kasan/common.c:47 kasan_save_track+0x16/0x28 mm/kasan/common.c:68 kasan_save_free_info+0x40/0x5c mm/kasan/generic.c:582 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x4e/0x68 mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:233 [inline] slab_free_hook mm/slub.c:2353 [inline] slab_free mm/slub.c:4613 [inline] kfree+0x13e/0x508 mm/slub.c:4761 tomoyo_realpath_from_path+0x19e/0x64a security/tomoyo/realpath.c:286 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_check_open_permission+0x2fe/0x3d6 security/tomoyo/file.c:771 tomoyo_file_open security/tomoyo/tomoyo.c:334 [inline] tomoyo_file_open+0xa0/0xc4 security/tomoyo/tomoyo.c:328 security_file_open+0xa8/0x250 security/security.c:3105 do_dentry_open+0x4de/0x1946 fs/open.c:928 vfs_open+0xbe/0x37c fs/open.c:1075 do_open fs/namei.c:3828 [inline] path_openat+0x1b70/0x28c2 fs/namei.c:3987 do_filp_open+0x19c/0x35c fs/namei.c:4014 do_sys_openat2+0x174/0x1ca fs/open.c:1402 do_sys_open fs/open.c:1417 [inline] __do_sys_openat fs/open.c:1433 [inline] __se_sys_openat fs/open.c:1428 [inline] __riscv_sys_openat+0x178/0x1fe fs/open.c:1428 syscall_handler+0x94/0x118 arch/riscv/include/asm/syscall.h:90 do_trap_ecall_u+0x1aa/0x216 arch/riscv/kernel/traps.c:331 handle_exception+0x146/0x152 arch/riscv/kernel/entry.S:197 The buggy address belongs to the object at ff6000002ecf8000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 2272 bytes to the right of allocated 4096-byte region [ff6000002ecf8000, ff6000002ecf9000) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xaecf8 head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0xffe000000000040(head|node=0|zone=0|lastcpupid=0x7ff) page_type: f5(slab) raw: 0ffe000000000040 ff60000011402140 dead000000000100 dead000000000122 raw: 0000000000000000 0000000000040004 00000001f5000000 0000000000000000 head: 0ffe000000000040 ff60000011402140 dead000000000100 dead000000000122 head: 0000000000000000 0000000000040004 00000001f5000000 0000000000000000 head: 0ffe000000000003 ff1c000000bb3e01 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 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3235, tgid 3235 (syz-executor), ts 8474946008300, free_ts 8472359561700 __set_page_owner+0xa2/0x70c mm/page_owner.c:320 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0xf0/0x1e8 mm/page_alloc.c:1556 prep_new_page mm/page_alloc.c:1564 [inline] get_page_from_freelist+0xdb0/0x2c0e mm/page_alloc.c:3474 __alloc_pages_noprof+0x1e8/0x1fc2 mm/page_alloc.c:4751 alloc_pages_mpol_noprof+0xf8/0x488 mm/mempolicy.c:2269 alloc_pages_noprof+0x174/0x2f0 mm/mempolicy.c:2348 alloc_slab_page mm/slub.c:2423 [inline] allocate_slab mm/slub.c:2589 [inline] new_slab+0x2b6/0x40e mm/slub.c:2642 ___slab_alloc+0x9c8/0x10e6 mm/slub.c:3830 __slab_alloc.constprop.0+0x60/0xb0 mm/slub.c:3920 __slab_alloc_node mm/slub.c:3995 [inline] slab_alloc_node mm/slub.c:4156 [inline] __do_kmalloc_node mm/slub.c:4297 [inline] __kmalloc_noprof+0x1dc/0x5ba mm/slub.c:4310 kmalloc_noprof include/linux/slab.h:905 [inline] tomoyo_realpath_from_path+0xb8/0x64a security/tomoyo/realpath.c:251 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_number_perm+0x28c/0x5a4 security/tomoyo/file.c:723 tomoyo_path_mkdir+0xa4/0xec security/tomoyo/tomoyo.c:179 security_path_mkdir+0x174/0x32e security/security.c:1927 do_mkdirat+0x150/0x32e fs/namei.c:4331 __do_sys_mkdirat fs/namei.c:4349 [inline] __se_sys_mkdirat fs/namei.c:4347 [inline] __riscv_sys_mkdirat+0x80/0xa0 fs/namei.c:4347 page last free pid 3159 tgid 3159 stack trace: __reset_page_owner+0x8c/0x400 mm/page_owner.c:297 reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1127 [inline] free_unref_page+0x618/0x11d2 mm/page_alloc.c:2657 __free_pages+0x13a/0x1ba mm/page_alloc.c:4838 __free_slab+0xd0/0x176 mm/slub.c:2659 free_slab+0x38/0x1ae mm/slub.c:2682 discard_slab+0x42/0x5a mm/slub.c:2688 __slab_free+0x346/0x3f6 mm/slub.c:4524 do_slab_free mm/slub.c:4565 [inline] ___cache_free+0x1a4/0x1de mm/slub.c:4671 qlink_free mm/kasan/quarantine.c:163 [inline] qlist_free_all+0x76/0x168 mm/kasan/quarantine.c:179 kasan_quarantine_reduce+0x158/0x1ba mm/kasan/quarantine.c:286 __kasan_slab_alloc+0x5c/0x82 mm/kasan/common.c:329 kasan_slab_alloc include/linux/kasan.h:250 [inline] slab_post_alloc_hook mm/slub.c:4119 [inline] slab_alloc_node mm/slub.c:4168 [inline] kmem_cache_alloc_node_noprof+0x10a/0x3e8 mm/slub.c:4220 __alloc_skb+0x32c/0x42a net/core/skbuff.c:668 alloc_skb_fclone include/linux/skbuff.h:1373 [inline] tcp_stream_alloc_skb+0x38/0x516 net/ipv4/tcp.c:886 tcp_sendmsg_locked+0x10aa/0x3692 net/ipv4/tcp.c:1168 tcp_sendmsg+0x32/0x4e net/ipv4/tcp.c:1358 Memory state around the buggy address: ff6000002ecf9780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ff6000002ecf9800: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ff6000002ecf9880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ^ ff6000002ecf9900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ff6000002ecf9980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================