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 ff600000449358e0 by task syz.5.4658/20114 CPU: 0 UID: 0 PID: 20114 Comm: syz.5.4658 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 19216: 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] __kmalloc_cache_noprof+0x15e/0x3f4 mm/slub.c:4329 kmalloc_noprof include/linux/slab.h:901 [inline] slab_free_hook mm/slub.c:2305 [inline] slab_free mm/slub.c:4613 [inline] kmem_cache_free+0x416/0x630 mm/slub.c:4715 sk_prot_free net/core/sock.c:2199 [inline] __sk_destruct+0x4d8/0x8a4 net/core/sock.c:2293 sk_destruct+0xc6/0xdc net/core/sock.c:2308 __sk_free+0x1b8/0x4d6 net/core/sock.c:2319 sk_free+0x86/0x9e net/core/sock.c:2330 sock_put include/net/sock.h:1904 [inline] tcp_close+0xf4/0x126 net/ipv4/tcp.c:3225 inet_release+0x116/0x23c net/ipv4/af_inet.c:435 inet6_release+0x58/0x7e net/ipv6/af_inet6.c:487 __sock_release+0xa4/0x246 net/socket.c:640 sock_close+0x1e/0x2a net/socket.c:1408 __fput+0x378/0x9ee fs/file_table.c:450 __fput_sync+0xd2/0x138 fs/file_table.c:535 __do_sys_close fs/open.c:1554 [inline] __se_sys_close fs/open.c:1539 [inline] __riscv_sys_close+0x76/0xe4 fs/open.c:1539 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 3160: 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 slab_free_after_rcu_debug+0x98/0x376 mm/slub.c:4650 rcu_do_batch kernel/rcu/tree.c:2567 [inline] rcu_core+0xa24/0x1ea0 kernel/rcu/tree.c:2823 rcu_core_si+0xc/0x14 kernel/rcu/tree.c:2840 handle_softirqs+0x4b2/0x132e kernel/softirq.c:561 __do_softirq kernel/softirq.c:595 [inline] invoke_softirq kernel/softirq.c:435 [inline] __irq_exit_rcu+0x18c/0x550 kernel/softirq.c:662 irq_exit_rcu+0x10/0xf8 kernel/softirq.c:678 handle_riscv_irq+0x40/0x4c arch/riscv/kernel/traps.c:378 call_on_irq_stack+0x32/0x40 arch/riscv/kernel/entry.S:356 Last potentially related work creation: stack_trace_save+0xa0/0xd2 kernel/stacktrace.c:122 kasan_save_stack+0x3e/0x6a mm/kasan/common.c:47 __kasan_record_aux_stack+0x118/0x166 mm/kasan/generic.c:544 kasan_record_aux_stack_noalloc+0xe/0x16 mm/kasan/generic.c:554 __call_rcu_common.constprop.0+0x9a/0x934 kernel/rcu/tree.c:3086 call_rcu+0xc/0x14 kernel/rcu/tree.c:3190 slab_free_hook mm/slub.c:2317 [inline] slab_free mm/slub.c:4613 [inline] kmem_cache_free+0x438/0x630 mm/slub.c:4715 sk_prot_free net/core/sock.c:2199 [inline] __sk_destruct+0x4d8/0x8a4 net/core/sock.c:2293 sk_destruct+0xc6/0xdc net/core/sock.c:2308 __sk_free+0x1b8/0x4d6 net/core/sock.c:2319 sk_free+0x86/0x9e net/core/sock.c:2330 sock_put include/net/sock.h:1904 [inline] tcp_close+0xf4/0x126 net/ipv4/tcp.c:3225 inet_release+0x116/0x23c net/ipv4/af_inet.c:435 inet6_release+0x58/0x7e net/ipv6/af_inet6.c:487 __sock_release+0xa4/0x246 net/socket.c:640 sock_close+0x1e/0x2a net/socket.c:1408 __fput+0x378/0x9ee fs/file_table.c:450 __fput_sync+0xd2/0x138 fs/file_table.c:535 __do_sys_close fs/open.c:1554 [inline] __se_sys_close fs/open.c:1539 [inline] __riscv_sys_close+0x76/0xe4 fs/open.c:1539 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 ff600000449358c0 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes to the right of allocated 32-byte region [ff600000449358c0, ff600000449358e0) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xff600000449350c0 pfn:0xc4935 flags: 0xffe000000000200(workingset|node=0|zone=0|lastcpupid=0x7ff) page_type: f5(slab) raw: 0ffe000000000200 ff60000011401780 ff1c000001103990 ff1c00000129f4d0 raw: ff600000449350c0 000000000040002e 00000001f5000000 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x52cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 15577, tgid 15577 (syz-executor), ts 9864906510700, free_ts 9864870995700 __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_node_noprof+0x1dc/0x5e8 mm/slub.c:4304 __kvmalloc_node_noprof+0xca/0x252 mm/util.c:650 kvmalloc_array_node_noprof include/linux/slab.h:1063 [inline] xt_alloc_entry_offsets+0x4a/0x76 net/netfilter/x_tables.c:968 translate_table+0x22c/0x15e2 net/ipv4/netfilter/ip_tables.c:678 do_replace+0x2f8/0x432 net/ipv4/netfilter/ip_tables.c:1137 do_ipt_set_ctl+0x39e/0x916 net/ipv4/netfilter/ip_tables.c:1635 nf_setsockopt+0x78/0xda net/netfilter/nf_sockopt.c:101 page last free pid 15577 tgid 15577 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 vfree+0x1b6/0xc82 mm/vmalloc.c:3382 copy_entries_to_user net/ipv4/netfilter/ip_tables.c:866 [inline] get_entries net/ipv4/netfilter/ip_tables.c:1022 [inline] do_ipt_get_ctl+0x748/0x920 net/ipv4/netfilter/ip_tables.c:1668 nf_getsockopt+0x6e/0xd2 net/netfilter/nf_sockopt.c:116 ip_getsockopt+0x276/0x584 net/ipv4/ip_sockglue.c:1777 tcp_getsockopt+0x84/0xd6 net/ipv4/tcp.c:4671 sock_common_getsockopt+0x86/0xb8 net/core/sock.c:3787 do_sock_getsockopt+0x37a/0x5ea net/socket.c:2374 __sys_getsockopt+0xd8/0x150 net/socket.c:2403 __do_sys_getsockopt net/socket.c:2410 [inline] __se_sys_getsockopt net/socket.c:2407 [inline] __riscv_sys_getsockopt+0xa6/0x114 net/socket.c:2407 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 Memory state around the buggy address: ff60000044935780: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc ff60000044935800: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc >ff60000044935880: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ^ ff60000044935900: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc ff60000044935980: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc ==================================================================