==================================================================
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 ffff88805466ec1c by task udevd/8228
CPU: 0 PID: 8228 Comm: udevd Not tainted 5.16.0-rc8-next-20220110-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
<IRQ>
__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
</IRQ>
<TASK>
asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:638
RIP: 0010:unwind_next_frame+0x830/0x1ce0 arch/x86/kernel/unwind_orc.c:466
Code: 07 38 d0 7f 08 84 c0 0f 85 12 12 00 00 41 80 7e 34 00 0f 85 00 fc ff ff 80 3d f6 6c 4b 0c 00 0f 85 f3 fb ff ff e9 5f 10 e0 07 <48> b8 00 00 00 00 00 fc ff df 48 8b 54 24 08 48 c1 ea 03 80 3c 02
RSP: 0018:ffffc9000b7376c0 EFLAGS: 00000297
RAX: 0000000000000005 RBX: 1ffff920016e6ee0 RCX: ffffffff8e3e1e95
RDX: 0000000000000005 RSI: 0000000000000001 RDI: 0000000000000001
RBP: 0000000000000001 R08: ffffffff8e3e1e90 R09: 0000000000000001
R10: fffff520016e6efe R11: 0000000000088078 R12: ffffc9000b7377e0
R13: ffffc9000b7377cd R14: ffffc9000b737798 R15: ffffffff8e3e1e94
arch_stack_walk+0x7d/0xe0 arch/x86/kernel/stacktrace.c:25
stack_trace_save+0x8c/0xc0 kernel/stacktrace.c:122
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:586 [inline]
kzalloc include/linux/slab.h:715 [inline]
tomoyo_encode2.part.0+0xe9/0x3a0 security/tomoyo/realpath.c:45
tomoyo_encode2 security/tomoyo/realpath.c:31 [inline]
tomoyo_encode+0x28/0x50 security/tomoyo/realpath.c:80
tomoyo_path_perm+0x368/0x400 security/tomoyo/file.c:831
tomoyo_path_symlink+0x94/0xe0 security/tomoyo/tomoyo.c:199
security_path_symlink+0xdf/0x150 security/security.c:1157
do_symlinkat+0x106/0x2e0 fs/namei.c:4323
__do_sys_symlink fs/namei.c:4350 [inline]
__se_sys_symlink fs/namei.c:4348 [inline]
__x64_sys_symlink+0x75/0x90 fs/namei.c:4348
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
RIP: 0033:0x7f248cfb7217
Code: f0 ff ff 73 01 c3 48 8b 0d 5e dc 0c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 b8 58 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 31 dc 0c 00 f7 d8 64 89 01 48
RSP: 002b:00007fff9ff8ad28 EFLAGS: 00000202 ORIG_RAX: 0000000000000058
RAX: ffffffffffffffda RBX: 00007fff9ff8ad38 RCX: 00007f248cfb7217
RDX: 0000000000000000 RSI: 00007fff9ff8ad38 RDI: 00007f248e898810
RBP: 00007f248e8a3420 R08: 0000000000001fff R09: 00007fff9ff8abd0
R10: 0000000000000000 R11: 0000000000000202 R12: 000000000000176e
R13: 00007f248e892650 R14: 0000000000000008 R15: 00007f248e878910
</TASK>
Allocated by task 13144:
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 16140:
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:155 [inline]
release_task+0xbd0/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
call_rcu+0x99/0x730 kernel/rcu/tree.c:3072
tnode_free+0xb5/0x120 net/ipv4/fib_trie.c:495
replace+0x120/0x4b0 net/ipv4/fib_trie.c:521
inflate net/ipv4/fib_trie.c:623 [inline]
resize+0xfc5/0x2170 net/ipv4/fib_trie.c:868
trie_rebalance net/ipv4/fib_trie.c:1094 [inline]
fib_remove_alias net/ipv4/fib_trie.c:1654 [inline]
fib_remove_alias+0x301/0x4a0 net/ipv4/fib_trie.c:1636
fib_table_delete+0x71c/0xa40 net/ipv4/fib_trie.c:1757
fib_magic+0x321/0x540 net/ipv4/fib_frontend.c:1089
fib_del_ifaddr+0xc97/0x13c0 net/ipv4/fib_frontend.c:1297
fib_inetaddr_event+0xb4/0x2a0 net/ipv4/fib_frontend.c:1428
notifier_call_chain+0xb5/0x200 kernel/notifier.c:84
blocking_notifier_call_chain kernel/notifier.c:319 [inline]
blocking_notifier_call_chain+0x67/0x90 kernel/notifier.c:307
__inet_del_ifa+0x415/0xf70 net/ipv4/devinet.c:430
inet_del_ifa net/ipv4/devinet.c:467 [inline]
inetdev_destroy net/ipv4/devinet.c:320 [inline]
inetdev_event+0x671/0x15d0 net/ipv4/devinet.c:1600
notifier_call_chain+0xb5/0x200 kernel/notifier.c:84
call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1919
call_netdevice_notifiers_mtu net/core/dev.c:1968 [inline]
dev_set_mtu_ext+0x39d/0x5b0 net/core/dev.c:8280
do_setlink+0x5e4/0x3a10 net/core/rtnetlink.c:2692
rtnl_setlink+0x24d/0x3c0 net/core/rtnetlink.c:3031
rtnetlink_rcv_msg+0x413/0xb80 net/core/rtnetlink.c:5592
netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494
netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
netlink_unicast+0x533/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_write_iter+0x289/0x3c0 net/socket.c:1061
call_write_iter include/linux/fs.h:2074 [inline]
do_iter_readv_writev+0x47a/0x750 fs/read_write.c:725
do_iter_write+0x188/0x710 fs/read_write.c:851
vfs_writev+0x1aa/0x630 fs/read_write.c:924
do_writev+0x27f/0x300 fs/read_write.c:967
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
Second to 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]
loop_queue_work drivers/block/loop.c:887 [inline]
loop_queue_rq+0x5f2/0xf50 drivers/block/loop.c:1829
__blk_mq_issue_directly block/blk-mq.c:2420 [inline]
__blk_mq_try_issue_directly+0x56a/0x790 block/blk-mq.c:2473
blk_mq_try_issue_directly+0x21/0x90 block/blk-mq.c:2497
blk_mq_submit_bio+0x1643/0x21c0 block/blk-mq.c:2850
__submit_bio block/blk-core.c:802 [inline]
__submit_bio_noacct_mq block/blk-core.c:877 [inline]
submit_bio_noacct block/blk-core.c:903 [inline]
submit_bio_noacct+0x82c/0xa20 block/blk-core.c:892
submit_bio block/blk-core.c:964 [inline]
submit_bio+0x1ea/0x430 block/blk-core.c:922
submit_bh_wbc+0x5e8/0x7e0 fs/buffer.c:3092
submit_bh fs/buffer.c:3098 [inline]
__sync_dirty_buffer+0x16b/0x3f0 fs/buffer.c:3193
udf_close_lvid+0x4a9/0x5c0 fs/udf/super.c:2094
udf_put_super+0x198/0x200 fs/udf/super.c:2359
generic_shutdown_super+0x14c/0x400 fs/super.c:462
kill_block_super+0x97/0xf0 fs/super.c:1394
deactivate_locked_super+0x94/0x160 fs/super.c:332
deactivate_super+0xad/0xd0 fs/super.c:363
cleanup_mnt+0x3a2/0x540 fs/namespace.c:1159
task_work_run+0xdd/0x1a0 kernel/task_work.c:164
tracehook_notify_resume include/linux/tracehook.h:189 [inline]
exit_to_user_mode_loop kernel/entry/common.c:175 [inline]
exit_to_user_mode_prepare+0x27e/0x290 kernel/entry/common.c:207
__syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x44/0xae
The buggy address belongs to the object at ffff88805466ec00
which belongs to the cache kmalloc-192 of size 192
The buggy address is located 28 bytes inside of
192-byte region [ffff88805466ec00, ffff88805466ecc0)
The buggy address belongs to the page:
page:ffffea0001519b80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5466e
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea000052f7c0 dead000000000004 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 20564, ts 781224628558, free_ts 781119971679
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
kmem_cache_zalloc include/linux/slab.h:705 [inline]
alloc_vfsmnt+0x23/0x6b0 fs/namespace.c:198
clone_mnt+0x6d/0x1080 fs/namespace.c:1077
copy_tree+0x3ad/0xae0 fs/namespace.c:1894
copy_mnt_ns+0x1a0/0xae0 fs/namespace.c:3450
create_new_namespaces+0xd6/0xb20 kernel/nsproxy.c:78
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_list+0x1a9/0xfa0 mm/page_alloc.c:3441
release_pages+0x818/0x18e0 mm/swap.c:980
tlb_batch_pages_flush mm/mmu_gather.c:50 [inline]
tlb_flush_mmu_free mm/mmu_gather.c:243 [inline]
tlb_flush_mmu mm/mmu_gather.c:250 [inline]
tlb_finish_mmu+0x165/0x8c0 mm/mmu_gather.c:341
exit_mmap+0x21b/0x670 mm/mmap.c:3181
__mmput+0x122/0x4b0 kernel/fork.c:1116
mmput+0x56/0x60 kernel/fork.c:1137
exit_mm kernel/exit.c:507 [inline]
do_exit+0xa44/0x2b10 kernel/exit.c:780
do_group_exit+0x128/0x330 kernel/exit.c:931
get_signal+0x4b0/0x28c0 kernel/signal.c:2868
arch_do_signal_or_restart+0x2a9/0x1c40 arch/x86/kernel/signal.c:868
handle_signal_work kernel/entry/common.c:148 [inline]
exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
exit_to_user_mode_prepare+0x17d/0x290 kernel/entry/common.c:207
__syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x44/0xae
Memory state around the buggy address:
ffff88805466eb00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88805466eb80: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
>ffff88805466ec00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88805466ec80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88805466ed00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================
----------------
Code disassembly (best guess), 1 bytes skipped:
0: 38 d0 cmp %dl,%al
2: 7f 08 jg 0xc
4: 84 c0 test %al,%al
6: 0f 85 12 12 00 00 jne 0x121e
c: 41 80 7e 34 00 cmpb $0x0,0x34(%r14)
11: 0f 85 00 fc ff ff jne 0xfffffc17
17: 80 3d f6 6c 4b 0c 00 cmpb $0x0,0xc4b6cf6(%rip) # 0xc4b6d14
1e: 0f 85 f3 fb ff ff jne 0xfffffc17
24: e9 5f 10 e0 07 jmpq 0x7e01088
* 29: 48 b8 00 00 00 00 00 movabs $0xdffffc0000000000,%rax <-- trapping instruction
30: fc ff df
33: 48 8b 54 24 08 mov 0x8(%rsp),%rdx
38: 48 c1 ea 03 shr $0x3,%rdx
3c: 80 .byte 0x80
3d: 3c 02 cmp $0x2,%al