================================================================== BUG: KASAN: use-after-free in instrument_atomic_read_write include/linux/instrumented.h:101 [inline] BUG: KASAN: use-after-free in atomic_add_unless include/linux/atomic/atomic-instrumented.h:607 [inline] BUG: KASAN: use-after-free in _atomic_dec_and_lock_irqsave+0x27/0x150 lib/dec_and_lock.c:41 Write of size 4 at addr ffff888070e04b1c by task kworker/u4:5/1058 CPU: 1 PID: 1058 Comm: kworker/u4:5 Not tainted 5.16.0-rc8-next-20220110-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: bat_events batadv_nc_worker Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0xa5/0x3e0 mm/kasan/report.c:255 __kasan_report mm/kasan/report.c:442 [inline] kasan_report.cold+0x83/0xdf mm/kasan/report.c:459 check_region_inline mm/kasan/generic.c:183 [inline] kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189 instrument_atomic_read_write include/linux/instrumented.h:101 [inline] atomic_add_unless include/linux/atomic/atomic-instrumented.h:607 [inline] _atomic_dec_and_lock_irqsave+0x27/0x150 lib/dec_and_lock.c:41 put_ucounts+0x73/0x1c0 kernel/ucount.c:206 put_cred_rcu+0x27a/0x520 kernel/cred.c:124 rcu_do_batch kernel/rcu/tree.c:2536 [inline] rcu_core+0x7b8/0x1540 kernel/rcu/tree.c:2787 __do_softirq+0x29b/0x9c2 kernel/softirq.c:558 invoke_softirq kernel/softirq.c:432 [inline] __irq_exit_rcu+0x123/0x180 kernel/softirq.c:637 irq_exit_rcu+0x5/0x20 kernel/softirq.c:649 sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1097 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:638 RIP: 0010:__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:152 [inline] RIP: 0010:_raw_spin_unlock_irqrestore+0x38/0x70 kernel/locking/spinlock.c:194 Code: 74 24 10 e8 ba 06 01 f8 48 89 ef e8 72 7c 01 f8 81 e3 00 02 00 00 75 25 9c 58 f6 c4 02 75 2d 48 85 db 74 01 fb bf 01 00 00 00 73 36 f4 f7 65 8b 05 6c 37 a6 76 85 c0 74 0a 5b 5d c3 e8 60 7a RSP: 0018:ffffc90005247bd8 EFLAGS: 00000206 RAX: 0000000000000006 RBX: 0000000000000200 RCX: 1ffffffff2004bf6 RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000001 RBP: ffffffff8bb8d040 R08: 0000000000000001 R09: ffffffff8ffd0a27 R10: 0000000000000001 R11: 1ffffffff1771a20 R12: 0000000000000001 R13: ffffffff8bb8d110 R14: 0000000000000004 R15: ffffffff8bb8d040 rcu_preempt_deferred_qs_irqrestore+0x4e3/0xb20 kernel/rcu/tree_plugin.h:556 rcu_read_unlock_special kernel/rcu/tree_plugin.h:671 [inline] __rcu_read_unlock+0x29c/0x570 kernel/rcu/tree_plugin.h:424 rcu_read_unlock include/linux/rcupdate.h:726 [inline] batadv_nc_purge_orig_hash net/batman-adv/network-coding.c:412 [inline] batadv_nc_worker+0x853/0xfa0 net/batman-adv/network-coding.c:719 process_one_work+0x9ac/0x1650 kernel/workqueue.c:2307 worker_thread+0x657/0x1110 kernel/workqueue.c:2454 kthread+0x2e9/0x3a0 kernel/kthread.c:377 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Allocated by task 4901: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:436 [inline] ____kasan_kmalloc mm/kasan/common.c:515 [inline] ____kasan_kmalloc mm/kasan/common.c:474 [inline] __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524 kmalloc include/linux/slab.h:581 [inline] kzalloc include/linux/slab.h:715 [inline] alloc_ucounts+0x1c3/0x590 kernel/ucount.c:175 set_cred_ucounts+0x163/0x320 kernel/cred.c:682 copy_creds+0x708/0xb50 kernel/cred.c:373 copy_process+0x1440/0x7300 kernel/fork.c:2034 kernel_clone+0xe7/0xab0 kernel/fork.c:2557 __do_sys_clone+0xc8/0x110 kernel/fork.c:2674 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Freed by task 3642: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track+0x21/0x30 mm/kasan/common.c:45 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:366 [inline] ____kasan_slab_free+0x166/0x1a0 mm/kasan/common.c:328 kasan_slab_free include/linux/kasan.h:236 [inline] slab_free_hook mm/slub.c:1728 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1754 slab_free mm/slub.c:3509 [inline] kfree+0xce/0x380 mm/slub.c:4562 put_ucounts+0x153/0x1c0 kernel/ucount.c:209 do_dec_rlimit_put_ucounts+0xfb/0x1a0 kernel/ucount.c:299 __sigqueue_free kernel/signal.c:455 [inline] __sigqueue_free kernel/signal.c:450 [inline] flush_sigqueue+0x18e/0x280 kernel/signal.c:469 __exit_signal kernel/exit.c:162 [inline] release_task+0xc2d/0x17e0 kernel/exit.c:200 wait_task_zombie kernel/exit.c:1116 [inline] wait_consider_task+0x2fa6/0x3b80 kernel/exit.c:1343 do_wait_thread kernel/exit.c:1406 [inline] do_wait+0x6ca/0xce0 kernel/exit.c:1523 kernel_wait4+0x14c/0x260 kernel/exit.c:1686 __do_sys_wait4+0x13f/0x150 kernel/exit.c:1714 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Last potentially related work creation: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348 insert_work+0x48/0x370 kernel/workqueue.c:1368 __queue_work+0x5ca/0xf30 kernel/workqueue.c:1534 queue_work_on+0xee/0x110 kernel/workqueue.c:1562 queue_work include/linux/workqueue.h:502 [inline] addr_event.part.0+0x326/0x4e0 drivers/infiniband/core/roce_gid_mgmt.c:853 addr_event drivers/infiniband/core/roce_gid_mgmt.c:824 [inline] inet6addr_event+0x13e/0x1b0 drivers/infiniband/core/roce_gid_mgmt.c:883 notifier_call_chain+0xb5/0x200 kernel/notifier.c:84 atomic_notifier_call_chain+0x70/0x180 kernel/notifier.c:199 ipv6_add_addr+0x16bf/0x1f30 net/ipv6/addrconf.c:1161 addrconf_add_linklocal+0x1ca/0x590 net/ipv6/addrconf.c:3197 addrconf_addr_gen+0x387/0x3d0 net/ipv6/addrconf.c:3328 addrconf_dev_config+0x255/0x420 net/ipv6/addrconf.c:3373 addrconf_notify+0xdb5/0x1ba0 net/ipv6/addrconf.c:3613 notifier_call_chain+0xb5/0x200 kernel/notifier.c:84 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1919 netdev_state_change net/core/dev.c:1309 [inline] netdev_state_change+0x100/0x130 net/core/dev.c:1302 linkwatch_do_dev+0x10e/0x150 net/core/link_watch.c:167 __linkwatch_run_queue+0x243/0x6b0 net/core/link_watch.c:220 linkwatch_event+0x4a/0x60 net/core/link_watch.c:263 process_one_work+0x9ac/0x1650 kernel/workqueue.c:2307 worker_thread+0x657/0x1110 kernel/workqueue.c:2454 kthread+0x2e9/0x3a0 kernel/kthread.c:377 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 The buggy address belongs to the object at ffff888070e04b00 which belongs to the cache kmalloc-192 of size 192 The buggy address is located 28 bytes inside of 192-byte region [ffff888070e04b00, ffff888070e04bc0) The buggy address belongs to the page: page:ffffea0001c38100 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x70e04 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 dead000000000100 dead000000000122 ffff888010c41a00 raw: 0000000000000000 0000000000100010 00000001ffffffff 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 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 3643, ts 169750160613, free_ts 169685347851 prep_new_page mm/page_alloc.c:2434 [inline] get_page_from_freelist+0xa72/0x2f40 mm/page_alloc.c:4165 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5381 __alloc_pages_node include/linux/gfp.h:568 [inline] alloc_slab_page mm/slub.c:1801 [inline] allocate_slab mm/slub.c:1944 [inline] new_slab+0xaf/0x380 mm/slub.c:2004 ___slab_alloc+0x6be/0xd60 mm/slub.c:3018 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3105 slab_alloc_node mm/slub.c:3196 [inline] __kmalloc_node+0x2cb/0x380 mm/slub.c:4468 kmalloc_array_node include/linux/slab.h:677 [inline] kcalloc_node include/linux/slab.h:682 [inline] memcg_alloc_slab_cgroups+0x8b/0x140 mm/memcontrol.c:2834 account_slab mm/slab.h:642 [inline] allocate_slab mm/slub.c:1960 [inline] new_slab+0x2f1/0x380 mm/slub.c:2004 ___slab_alloc+0x6be/0xd60 mm/slub.c:3018 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3105 slab_alloc_node mm/slub.c:3196 [inline] slab_alloc mm/slub.c:3238 [inline] kmem_cache_alloc+0x35c/0x3a0 mm/slub.c:3243 sock_alloc_inode+0x18/0x1c0 net/socket.c:304 alloc_inode+0x61/0x230 fs/inode.c:260 new_inode_pseudo+0x14/0xe0 fs/inode.c:1018 sock_alloc+0x3c/0x260 net/socket.c:627 __sock_create+0xb9/0x790 net/socket.c:1432 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1352 [inline] free_pcp_prepare+0x414/0xb60 mm/page_alloc.c:1404 free_unref_page_prepare mm/page_alloc.c:3325 [inline] free_unref_page+0x19/0x690 mm/page_alloc.c:3404 __vunmap+0x854/0xd30 mm/vmalloc.c:2637 __vfree+0x3c/0xd0 mm/vmalloc.c:2685 vfree+0x5a/0x90 mm/vmalloc.c:2716 netlink_skb_destructor+0xc2/0x210 net/netlink/af_netlink.c:377 skb_release_head_state+0x9f/0x2a0 net/core/skbuff.c:729 skb_release_all net/core/skbuff.c:740 [inline] __kfree_skb net/core/skbuff.c:756 [inline] consume_skb net/core/skbuff.c:912 [inline] consume_skb+0x89/0x160 net/core/skbuff.c:906 netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline] netlink_unicast+0x53b/0x7d0 net/netlink/af_netlink.c:1343 netlink_sendmsg+0x904/0xdf0 net/netlink/af_netlink.c:1919 sock_sendmsg_nosec net/socket.c:705 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:725 sock_no_sendpage+0xf6/0x140 net/core/sock.c:3086 kernel_sendpage.part.0+0x1ff/0x7b0 net/socket.c:3492 kernel_sendpage net/socket.c:3489 [inline] sock_sendpage+0xe5/0x140 net/socket.c:1007 pipe_to_sendpage+0x2ad/0x380 fs/splice.c:364 splice_from_pipe_feed fs/splice.c:418 [inline] __splice_from_pipe+0x43e/0x8a0 fs/splice.c:562 Memory state around the buggy address: ffff888070e04a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff888070e04a80: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc >ffff888070e04b00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888070e04b80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff888070e04c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ================================================================== ---------------- Code disassembly (best guess): 0: 74 24 je 0x26 2: 10 e8 adc %ch,%al 4: ba 06 01 f8 48 mov $0x48f80106,%edx 9: 89 ef mov %ebp,%edi b: e8 72 7c 01 f8 callq 0xf8017c82 10: 81 e3 00 02 00 00 and $0x200,%ebx 16: 75 25 jne 0x3d 18: 9c pushfq 19: 58 pop %rax 1a: f6 c4 02 test $0x2,%ah 1d: 75 2d jne 0x4c 1f: 48 85 db test %rbx,%rbx 22: 74 01 je 0x25 24: fb sti 25: bf 01 00 00 00 mov $0x1,%edi * 2a: e8 73 36 f4 f7 callq 0xf7f436a2 <-- trapping instruction 2f: 65 8b 05 6c 37 a6 76 mov %gs:0x76a6376c(%rip),%eax # 0x76a637a2 36: 85 c0 test %eax,%eax 38: 74 0a je 0x44 3a: 5b pop %rbx 3b: 5d pop %rbp 3c: c3 retq 3d: e8 .byte 0xe8 3e: 60 (bad) 3f: 7a .byte 0x7a