[v5.15] WARNING: refcount bug in qrtr_node_lookup

16 views
Skip to first unread message

syzbot

unread,
Mar 16, 2023, 9:49:52 AM3/16/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 2ddbd0f967b3 Linux 5.15.102
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=10d411e2c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=d6af46e4bd7d6a2f
dashboard link: https://syzkaller.appspot.com/bug?extid=d4c3e0920771e38a6831
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=104c3a72c80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13761fc6c80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/d46a989959b6/disk-2ddbd0f9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/4d06a9b2ddaf/vmlinux-2ddbd0f9.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0921009430c0/Image-2ddbd0f9.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+d4c3e0...@syzkaller.appspotmail.com

------------[ cut here ]------------
refcount_t: addition on 0; use-after-free.
WARNING: CPU: 0 PID: 136 at lib/refcount.c:25 refcount_warn_saturate+0x1a8/0x20c lib/refcount.c:25
Modules linked in:
CPU: 0 PID: 136 Comm: kworker/u4:1 Not tainted 5.15.102-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Workqueue: qrtr_ns_handler qrtr_ns_worker
pstate: 604000c5 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : refcount_warn_saturate+0x1a8/0x20c lib/refcount.c:25
lr : refcount_warn_saturate+0x1a8/0x20c lib/refcount.c:25
sp : ffff800018e66e40
x29: ffff800018e66e40 x28: dfff800000000000 x27: ffff7000031ccddc
x26: ffff800018e66f00 x25: 0000000000000000 x24: 00000000003a6056
x23: ffff0000cc2ff670 x22: 0000000000000000 x21: 0000000000000002
x20: ffff0000ce43e098 x19: ffff800016dd0000 x18: 0000000000000002
x17: ff808000083386a0 x16: ffff800011a080c4 x15: ffff8000083386a0
x14: 00000000ffffffff x13: ffffffffffffffff x12: 0000000000000000
x11: ff80800008330148 x10: 0000000000000000 x9 : 88691575a4efc200
x8 : 88691575a4efc200 x7 : 0000000000000001 x6 : 0000000000000001
x5 : ffff800018e665b8 x4 : ffff800014aa0700 x3 : ffff8000085518f8
x2 : 0000000000000001 x1 : 0000000100000001 x0 : 000000000000002a
Call trace:
refcount_warn_saturate+0x1a8/0x20c lib/refcount.c:25
__refcount_inc include/linux/refcount.h:250 [inline]
refcount_inc include/linux/refcount.h:267 [inline]
kref_get include/linux/kref.h:45 [inline]
qrtr_node_acquire net/qrtr/qrtr.c:202 [inline]
qrtr_node_lookup+0xe0/0x110 net/qrtr/qrtr.c:398
qrtr_send_resume_tx net/qrtr/qrtr.c:1003 [inline]
qrtr_recvmsg+0x3e0/0x958 net/qrtr/qrtr.c:1071
sock_recvmsg_nosec net/socket.c:947 [inline]
sock_recvmsg net/socket.c:965 [inline]
kernel_recvmsg+0x128/0x154 net/socket.c:990
qrtr_ns_worker+0x25c/0x4fb8 net/qrtr/ns.c:687
process_one_work+0x84c/0x14b8 kernel/workqueue.c:2306
worker_thread+0x910/0x1034 kernel/workqueue.c:2453
kthread+0x37c/0x45c kernel/kthread.c:319
ret_from_fork+0x10/0x20 <unknown>:870
irq event stamp: 142944
hardirqs last enabled at (142943): [<ffff800011adb7e0>] __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:160 [inline]
hardirqs last enabled at (142943): [<ffff800011adb7e0>] _raw_spin_unlock_irqrestore+0xac/0x158 kernel/locking/spinlock.c:194
hardirqs last disabled at (142944): [<ffff800011adb2bc>] __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:108 [inline]
hardirqs last disabled at (142944): [<ffff800011adb2bc>] _raw_spin_lock_irqsave+0xfc/0x14c kernel/locking/spinlock.c:162
softirqs last enabled at (142940): [<ffff80000fdc01a0>] spin_unlock_bh include/linux/spinlock.h:408 [inline]
softirqs last enabled at (142940): [<ffff80000fdc01a0>] lock_sock_nested+0x160/0x1ec net/core/sock.c:3223
softirqs last disabled at (142938): [<ffff80000fdc0148>] spin_lock_bh include/linux/spinlock.h:368 [inline]
softirqs last disabled at (142938): [<ffff80000fdc0148>] lock_sock_nested+0x108/0x1ec net/core/sock.c:3219
---[ end trace c5272773e48d5854 ]---


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Mar 16, 2023, 11:42:43 AM3/16/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 6449a0ba6843 Linux 6.1.19
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=13ee6c76c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=75eadb21ef1208e4
dashboard link: https://syzkaller.appspot.com/bug?extid=e50a4f7393c85a5b2dfa
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14997b8ac80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=142ba788c80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/dc227ecd3e21/disk-6449a0ba.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/1d08e21b50c2/vmlinux-6449a0ba.xz
kernel image: https://storage.googleapis.com/syzbot-assets/71a43f2c4d2c/Image-6449a0ba.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+e50a4f...@syzkaller.appspotmail.com

------------[ cut here ]------------
refcount_t: addition on 0; use-after-free.
WARNING: CPU: 0 PID: 1596 at lib/refcount.c:25 refcount_warn_saturate+0x1a8/0x20c lib/refcount.c:25
Modules linked in:
CPU: 0 PID: 1596 Comm: kworker/u4:4 Not tainted 6.1.19-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Workqueue: qrtr_ns_handler qrtr_ns_worker
pstate: 604000c5 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : refcount_warn_saturate+0x1a8/0x20c lib/refcount.c:25
lr : refcount_warn_saturate+0x1a8/0x20c lib/refcount.c:25
sp : ffff800022036da0
x29: ffff800022036da0 x28: dfff800000000000 x27: ffff700004406dc8
x26: ffff800022036e60 x25: 0000000000000000 x24: 00000000003a6056
x23: ffff0000c26c58f0 x22: 0000000000000000 x21: 0000000000000002
x20: ffff0000db455498 x19: ffff800018053000 x18: ffff8000220361a0
x17: 0000000000000000 x16: ffff800012253e1c x15: 0000000000000000
x14: 0000000000000000 x13: 0000000000000001 x12: 0000000000000001
x11: ff808000081b28cc x10: 0000000000000000 x9 : b18c0c206b39e600
x8 : b18c0c206b39e600 x7 : 0000000000000001 x6 : 0000000000000001
x5 : ffff800022036698 x4 : ffff800015813880 x3 : ffff800008590318
x2 : 0000000000000001 x1 : 0000000100000001 x0 : 0000000000000000
Call trace:
refcount_warn_saturate+0x1a8/0x20c lib/refcount.c:25
__refcount_inc include/linux/refcount.h:250 [inline]
refcount_inc include/linux/refcount.h:267 [inline]
kref_get include/linux/kref.h:45 [inline]
qrtr_node_acquire net/qrtr/af_qrtr.c:202 [inline]
qrtr_node_lookup+0xdc/0x100 net/qrtr/af_qrtr.c:398
qrtr_send_resume_tx net/qrtr/af_qrtr.c:1003 [inline]
qrtr_recvmsg+0x3dc/0x954 net/qrtr/af_qrtr.c:1070
sock_recvmsg_nosec net/socket.c:1000 [inline]
sock_recvmsg net/socket.c:1018 [inline]
kernel_recvmsg+0x128/0x154 net/socket.c:1043
qrtr_ns_worker+0x294/0x513c net/qrtr/ns.c:687
process_one_work+0x868/0x16f4 kernel/workqueue.c:2289
worker_thread+0x8e4/0xfec kernel/workqueue.c:2436
kthread+0x24c/0x2d4 kernel/kthread.c:376
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860
irq event stamp: 33478
hardirqs last enabled at (33477): [<ffff800012332a3c>] __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:151 [inline]
hardirqs last enabled at (33477): [<ffff800012332a3c>] _raw_spin_unlock_irqrestore+0x48/0xac kernel/locking/spinlock.c:194
hardirqs last disabled at (33478): [<ffff800012332858>] __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:108 [inline]
hardirqs last disabled at (33478): [<ffff800012332858>] _raw_spin_lock_irqsave+0xa4/0xb4 kernel/locking/spinlock.c:162
softirqs last enabled at (33474): [<ffff80001048f9ac>] spin_unlock_bh include/linux/spinlock.h:395 [inline]
softirqs last enabled at (33474): [<ffff80001048f9ac>] lock_sock_nested+0xe8/0x138 net/core/sock.c:3464
softirqs last disabled at (33472): [<ffff80001048f954>] spin_lock_bh include/linux/spinlock.h:355 [inline]
softirqs last disabled at (33472): [<ffff80001048f954>] lock_sock_nested+0x90/0x138 net/core/sock.c:3460
---[ end trace 0000000000000000 ]---
==================================================================
BUG: KASAN: use-after-free in __mutex_lock_common+0x100/0x21a0 kernel/locking/mutex.c:582
Read of size 8 at addr ffff0000db455460 by task kworker/u4:4/1596

CPU: 0 PID: 1596 Comm: kworker/u4:4 Tainted: G W 6.1.19-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Workqueue: qrtr_ns_handler qrtr_ns_worker
Call trace:
dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:284 [inline]
print_report+0x174/0x4c0 mm/kasan/report.c:395
kasan_report+0xd4/0x130 mm/kasan/report.c:495
__asan_report_load8_noabort+0x2c/0x38 mm/kasan/report_generic.c:351
__mutex_lock_common+0x100/0x21a0 kernel/locking/mutex.c:582
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
qrtr_node_enqueue+0x31c/0x9cc net/qrtr/af_qrtr.c:371
qrtr_send_resume_tx net/qrtr/af_qrtr.c:1015 [inline]
qrtr_recvmsg+0x510/0x954 net/qrtr/af_qrtr.c:1070
sock_recvmsg_nosec net/socket.c:1000 [inline]
sock_recvmsg net/socket.c:1018 [inline]
kernel_recvmsg+0x128/0x154 net/socket.c:1043
qrtr_ns_worker+0x294/0x513c net/qrtr/ns.c:687
process_one_work+0x868/0x16f4 kernel/workqueue.c:2289
worker_thread+0x8e4/0xfec kernel/workqueue.c:2436
kthread+0x24c/0x2d4 kernel/kthread.c:376
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860

Allocated by task 4401:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
kasan_save_alloc_info+0x24/0x30 mm/kasan/generic.c:505
____kasan_kmalloc mm/kasan/common.c:374 [inline]
__kasan_kmalloc+0xac/0xc4 mm/kasan/common.c:383
kasan_kmalloc include/linux/kasan.h:211 [inline]
kmalloc_trace+0x7c/0x94 mm/slab_common.c:1050
kmalloc include/linux/slab.h:553 [inline]
kzalloc include/linux/slab.h:689 [inline]
qrtr_endpoint_register+0x8c/0x3f4 net/qrtr/af_qrtr.c:583
qrtr_tun_open+0x130/0x1ac net/qrtr/tun.c:47
misc_open+0x2f0/0x368 drivers/char/misc.c:143
chrdev_open+0x3e8/0x4fc fs/char_dev.c:414
do_dentry_open+0x734/0xfa0 fs/open.c:882
vfs_open+0x7c/0x90 fs/open.c:1013
do_open fs/namei.c:3557 [inline]
path_openat+0x1e14/0x2548 fs/namei.c:3714
do_filp_open+0x1bc/0x3cc fs/namei.c:3741
do_sys_openat2+0x128/0x3d8 fs/open.c:1310
do_sys_open fs/open.c:1326 [inline]
__do_sys_openat fs/open.c:1342 [inline]
__se_sys_openat fs/open.c:1337 [inline]
__arm64_sys_openat+0x1f0/0x240 fs/open.c:1337
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

Freed by task 4401:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
kasan_save_free_info+0x38/0x5c mm/kasan/generic.c:516
____kasan_slab_free+0x144/0x1c0 mm/kasan/common.c:236
__kasan_slab_free+0x18/0x28 mm/kasan/common.c:244
kasan_slab_free include/linux/kasan.h:177 [inline]
slab_free_hook mm/slub.c:1724 [inline]
slab_free_freelist_hook mm/slub.c:1750 [inline]
slab_free mm/slub.c:3661 [inline]
__kmem_cache_free+0x2c0/0x4b4 mm/slub.c:3674
kfree+0x104/0x228 mm/slab_common.c:1007
__qrtr_node_release net/qrtr/af_qrtr.c:195 [inline]
kref_put_mutex include/linux/kref.h:76 [inline]
qrtr_node_release+0x444/0x498 net/qrtr/af_qrtr.c:211
qrtr_endpoint_unregister+0x59c/0x6cc net/qrtr/af_qrtr.c:649
qrtr_tun_release+0x44/0x68 net/qrtr/tun.c:131
__fput+0x30c/0x7bc fs/file_table.c:320
____fput+0x20/0x30 fs/file_table.c:348
task_work_run+0x240/0x2f0 kernel/task_work.c:179
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
do_notify_resume+0x2144/0x3470 arch/arm64/kernel/signal.c:1132
prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:137 [inline]
exit_to_user_mode arch/arm64/kernel/entry-common.c:142 [inline]
el0_svc+0x9c/0x168 arch/arm64/kernel/entry-common.c:638
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

The buggy address belongs to the object at ffff0000db455400
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 96 bytes inside of
512-byte region [ffff0000db455400, ffff0000db455600)

The buggy address belongs to the physical page:
page:000000003cdd2af7 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11b454
head:000000003cdd2af7 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x5ffc00000010200(slab|head|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000010200 0000000000000000 dead000000000001 ffff0000c0002600
raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff0000db455300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff0000db455380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff0000db455400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff0000db455480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff0000db455500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

syzbot

unread,
Apr 15, 2023, 4:09:27 PM4/15/23
to syzkaller...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit b9ba5906c42089f8e1d0001b7b50a7940f086cbb
Author: Ziyang Xuan <william.x...@huawei.com>
Date: Thu Mar 30 01:25:32 2023 +0000

net: qrtr: Fix a refcount bug in qrtr_recvmsg()

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1446a71fc80000
start commit: 2ddbd0f967b3 Linux 5.15.102
git tree: linux-5.15.y
If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: net: qrtr: Fix a refcount bug in qrtr_recvmsg()

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

syzbot

unread,
Apr 16, 2023, 1:44:32 AM4/16/23
to syzkaller...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit aa95efa187b4114075f312b3c4680d050b56fdec
Author: Ziyang Xuan <william.x...@huawei.com>
Date: Thu Mar 30 01:25:32 2023 +0000

net: qrtr: Fix a refcount bug in qrtr_recvmsg()

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1143b37bc80000
start commit: 6449a0ba6843 Linux 6.1.19
git tree: linux-6.1.y
Reply all
Reply to author
Forward
0 new messages