[syzbot] [v9fs?] WARNING: refcount bug in p9_req_put (4)

2 views
Skip to first unread message

syzbot

unread,
7:35 AM (16 hours ago) 7:35 AM
to asma...@codewreck.org, eri...@kernel.org, linux-...@vger.kernel.org, linu...@crudebyte.com, lu...@ionkov.net, syzkall...@googlegroups.com, v9...@lists.linux.dev
Hello,

syzbot found the following issue on:

HEAD commit: ba3e43a9e601 Merge tag 'soc-fixes-7.1-2' of git://git.kern..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12b65a86580000
kernel config: https://syzkaller.appspot.com/x/.config?x=8118209836970b54
dashboard link: https://syzkaller.appspot.com/bug?extid=f6fdb3bdd2c1d419e263
compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=158b5f2e580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13d47dd2580000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/d900f083ada3/non_bootable_disk-ba3e43a9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/12db9228338c/vmlinux-ba3e43a9.xz
kernel image: https://storage.googleapis.com/syzbot-assets/c8dfb3210b18/bzImage-ba3e43a9.xz

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

9pnet: Tag 0 still in use
------------[ cut here ]------------
refcount_t: underflow; use-after-free.
WARNING: lib/refcount.c:28 at refcount_warn_saturate+0xf4/0x130 lib/refcount.c:28, CPU#2: syz-executor/5869
Modules linked in:
CPU: 2 UID: 0 PID: 5869 Comm: syz-executor Not tainted syzkaller #0 PREEMPT(full)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:refcount_warn_saturate+0xf4/0x130 lib/refcount.c:28
Code: cc e8 b0 53 0f fd 48 8d 3d 89 44 e8 0b 67 48 0f b9 3a e8 9f 53 0f fd 5b 5d e9 d8 4f 93 06 e8 93 53 0f fd 48 8d 3d 7c 44 e8 0b <67> 48 0f b9 3a e8 82 53 0f fd 5b 5d c3 cc cc cc cc e8 76 53 0f fd
RSP: 0018:ffffc900060a7c38 EFLAGS: 00010293
RAX: 0000000000000000 RBX: ffff88803ecb7218 RCX: ffffffff84f95c3b
RDX: ffff88802b710000 RSI: ffffffff84f95ccd RDI: ffffffff90e1a150
RBP: 0000000000000003 R08: 0000000000000005 R09: 0000000000000004
R10: 0000000000000003 R11: 0000000000000000 R12: ffff88803ecb7218
R13: ffff888035c59800 R14: ffffc900060a7cc8 R15: ffff88801fa88040
FS: 000055557717e500(0000) GS:ffff8880d6583000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055e3b8556be0 CR3: 0000000037a35000 CR4: 0000000000352ef0
Call Trace:
<TASK>
__refcount_sub_and_test include/linux/refcount.h:400 [inline]
__refcount_dec_and_test include/linux/refcount.h:432 [inline]
refcount_dec_and_test include/linux/refcount.h:450 [inline]
p9_req_put+0x1ec/0x250 net/9p/client.c:281
p9_tag_cleanup net/9p/client.c:308 [inline]
p9_client_destroy.cold+0x20/0xe9 net/9p/client.c:963
v9fs_session_close+0x49/0x2d0 fs/9p/v9fs.c:543
v9fs_kill_super+0x4d/0xa0 fs/9p/vfs_super.c:175
deactivate_locked_super+0xc1/0x1b0 fs/super.c:476
deactivate_super fs/super.c:509 [inline]
deactivate_super+0xe7/0x110 fs/super.c:505
cleanup_mnt+0x21f/0x450 fs/namespace.c:1312
task_work_run+0x150/0x240 kernel/task_work.c:233
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
__exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
exit_to_user_mode_loop+0x157/0x670 kernel/entry/common.c:98
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:230 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:318 [inline]
do_syscall_64+0x666/0x870 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fbad779e097
Code: a2 c7 05 5c 06 25 00 00 00 00 00 eb 96 e8 e1 12 00 00 90 31 f6 e9 09 00 00 00 66 0f 1f 84 00 00 00 00 00 b8 a6 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 01 c3 48 c7 c2 e8 ff ff ff f7 d8 64 89 02 b8
RSP: 002b:00007fffe847bc88 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
RAX: 0000000000000000 RBX: 00007fbad78321ca RCX: 00007fbad779e097
RDX: 0000000000000000 RSI: 0000000000000009 RDI: 00007fffe847bd40
RBP: 00007fffe847bd40 R08: 00007fffe847cd40 R09: 00000000ffffffff
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fffe847cdd0
R13: 00007fbad78321ca R14: 000000000004828a R15: 00007fffe847ce10
</TASK>
----------------
Code disassembly (best guess):
0: cc int3
1: e8 b0 53 0f fd call 0xfd0f53b6
6: 48 8d 3d 89 44 e8 0b lea 0xbe84489(%rip),%rdi # 0xbe84496
d: 67 48 0f b9 3a ud1 (%edx),%rdi
12: e8 9f 53 0f fd call 0xfd0f53b6
17: 5b pop %rbx
18: 5d pop %rbp
19: e9 d8 4f 93 06 jmp 0x6934ff6
1e: e8 93 53 0f fd call 0xfd0f53b6
23: 48 8d 3d 7c 44 e8 0b lea 0xbe8447c(%rip),%rdi # 0xbe844a6
* 2a: 67 48 0f b9 3a ud1 (%edx),%rdi <-- trapping instruction
2f: e8 82 53 0f fd call 0xfd0f53b6
34: 5b pop %rbx
35: 5d pop %rbp
36: c3 ret
37: cc int3
38: cc int3
39: cc int3
3a: cc int3
3b: e8 76 53 0f fd call 0xfd0f53b6


---
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.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

Hillf Danton

unread,
9:11 AM (14 hours ago) 9:11 AM
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
> Date: Sat, 06 Jun 2026 04:35:28 -0700 [thread overview]
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: ba3e43a9e601 Merge tag 'soc-fixes-7.1-2' of git://git.kern..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=12b65a86580000
> kernel config: https://syzkaller.appspot.com/x/.config?x=8118209836970b54
> dashboard link: https://syzkaller.appspot.com/bug?extid=f6fdb3bdd2c1d419e263
> compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=158b5f2e580000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13d47dd2580000

#syz test

--- x/net/9p/client.c
+++ y/net/9p/client.c
@@ -181,11 +181,18 @@ p9_tag_alloc(struct p9_client *c, int8_t
p9pdu_reset(&req->rc);
req->t_err = 0;
req->status = REQ_STATUS_ALLOC;
- /* refcount needs to be set to 0 before inserting into the idr
- * so p9_tag_lookup does not accept a request that is not fully
- * initialized. refcount_set to 2 below will mark request ready.
+ req->tc.tag = -1;
+ /* Init ref to two because in the general case there is one ref
+ * that is put asynchronously by a writer thread, one ref
+ * temporarily given by p9_tag_lookup and put by p9_client_cb
+ * in the recv thread, and one ref put by p9_req_put in the
+ * main thread. The only exception is virtio that does not use
+ * p9_tag_lookup but does not have a writer thread either
+ * (the write happens synchronously in the request/zc_request
+ * callback), so p9_client_cb eats the second ref there
+ * as the pointer is duplicated directly by virtqueue_add_sgs()
*/
- refcount_set(&req->refcount, 0);
+ refcount_set(&req->refcount, 2);
init_waitqueue_head(&req->wq);
INIT_LIST_HEAD(&req->req_list);

@@ -202,18 +209,6 @@ p9_tag_alloc(struct p9_client *c, int8_t
if (tag < 0)
goto free;

- /* Init ref to two because in the general case there is one ref
- * that is put asynchronously by a writer thread, one ref
- * temporarily given by p9_tag_lookup and put by p9_client_cb
- * in the recv thread, and one ref put by p9_req_put in the
- * main thread. The only exception is virtio that does not use
- * p9_tag_lookup but does not have a writer thread either
- * (the write happens synchronously in the request/zc_request
- * callback), so p9_client_cb eats the second ref there
- * as the pointer is duplicated directly by virtqueue_add_sgs()
- */
- refcount_set(&req->refcount, 2);
-
return req;

free:
--

syzbot

unread,
9:33 AM (14 hours ago) 9:33 AM
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING: refcount bug in p9_req_put

------------[ cut here ]------------
refcount_t: underflow; use-after-free.
WARNING: lib/refcount.c:28 at refcount_warn_saturate+0xf4/0x130 lib/refcount.c:28, CPU#3: swapper/3/0
Modules linked in:
CPU: 3 UID: 0 PID: 0 Comm: swapper/3 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:refcount_warn_saturate+0xf4/0x130 lib/refcount.c:28
Code: cc e8 10 53 0f fd 48 8d 3d 89 4c e8 0b 67 48 0f b9 3a e8 ff 52 0f fd 5b 5d e9 d8 5f 93 06 e8 f3 52 0f fd 48 8d 3d 7c 4c e8 0b <67> 48 0f b9 3a e8 e2 52 0f fd 5b 5d c3 cc cc cc cc e8 d6 52 0f fd
RSP: 0018:ffffc900006f8d90 EFLAGS: 00010046
RAX: 0000000080010002 RBX: ffff8880341eb658 RCX: ffffffff84f95c3b
RDX: ffff88801eac2540 RSI: ffffffff84f95ccd RDI: ffffffff90e1a950
RBP: 0000000000000003 R08: 0000000000000005 R09: 0000000000000004
R10: 0000000000000003 R11: 0000000000000001 R12: ffff8880341eb658
R13: ffff8880287ccc00 R14: 000000000000000b R15: 1ffff1100465880c
FS: 0000000000000000(0000) GS:ffff8880d6687000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00001e1e2cc78000 CR3: 00000000389b6000 CR4: 0000000000352ef0
Call Trace:
<IRQ>
__refcount_sub_and_test include/linux/refcount.h:400 [inline]
__refcount_dec_and_test include/linux/refcount.h:432 [inline]
refcount_dec_and_test include/linux/refcount.h:450 [inline]
p9_req_put+0x1ec/0x250 net/9p/client.c:276
req_done+0x1dc/0x2e0 net/9p/trans_virtio.c:147
vring_interrupt+0x2ef/0x650 drivers/virtio/virtio_ring.c:3254
__handle_irq_event_percpu+0x235/0x8c0 kernel/irq/handle.c:209
handle_irq_event_percpu kernel/irq/handle.c:246 [inline]
handle_irq_event+0xab/0x1e0 kernel/irq/handle.c:263
handle_edge_irq+0x35e/0x960 kernel/irq/chip.c:857
generic_handle_irq_desc include/linux/irqdesc.h:186 [inline]
handle_irq arch/x86/kernel/irq.c:262 [inline]
call_irq_handler arch/x86/kernel/irq.c:318 [inline]
__common_interrupt+0xd8/0x2f0 arch/x86/kernel/irq.c:333
common_interrupt+0xb9/0xe0 arch/x86/kernel/irq.c:326
</IRQ>
<TASK>
asm_common_interrupt+0x26/0x40 arch/x86/include/asm/idtentry.h:688
RIP: 0010:pv_native_safe_halt+0xf/0x20 arch/x86/kernel/paravirt.c:63
Code: a6 92 02 e9 43 44 03 00 0f 1f 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa eb 07 0f 00 2d 23 02 22 00 fb f4 <c3> cc cc cc cc 66 2e 0f 1f 84 00 00 00 00 00 66 90 90 90 90 90 90
RSP: 0018:ffffc90000197df0 EFLAGS: 00000202
RAX: 0000000000162557 RBX: ffff88801eac2540 RCX: ffffffff8b899225
RDX: 0000000000000000 RSI: ffffffff8df0fbdb RDI: ffffffff8c1c4680
RBP: 0000000000000000 R08: 0000000000000001 R09: ffffed100d4e67b5
R10: ffff88806a733dab R11: 0000000000000000 R12: 0000000000000003
R13: ffffed1003d584a8 R14: 0000000000000003 R15: ffffffff90d71950
arch_safe_halt arch/x86/include/asm/paravirt.h:62 [inline]
default_idle+0x9/0x10 arch/x86/kernel/process.c:767
default_idle_call+0x6c/0xb0 kernel/sched/idle.c:122
cpuidle_idle_call kernel/sched/idle.c:199 [inline]
do_idle+0x464/0x590 kernel/sched/idle.c:352
cpu_startup_entry+0x4f/0x60 kernel/sched/idle.c:451
start_secondary+0x21d/0x2d0 arch/x86/kernel/smpboot.c:312
common_startup_64+0x13e/0x148
</TASK>
----------------
Code disassembly (best guess):
0: cc int3
1: e8 10 53 0f fd call 0xfd0f5316
6: 48 8d 3d 89 4c e8 0b lea 0xbe84c89(%rip),%rdi # 0xbe84c96
d: 67 48 0f b9 3a ud1 (%edx),%rdi
12: e8 ff 52 0f fd call 0xfd0f5316
17: 5b pop %rbx
18: 5d pop %rbp
19: e9 d8 5f 93 06 jmp 0x6935ff6
1e: e8 f3 52 0f fd call 0xfd0f5316
23: 48 8d 3d 7c 4c e8 0b lea 0xbe84c7c(%rip),%rdi # 0xbe84ca6
* 2a: 67 48 0f b9 3a ud1 (%edx),%rdi <-- trapping instruction
2f: e8 e2 52 0f fd call 0xfd0f5316
34: 5b pop %rbx
35: 5d pop %rbp
36: c3 ret
37: cc int3
38: cc int3
39: cc int3
3a: cc int3
3b: e8 d6 52 0f fd call 0xfd0f5316


Tested on:

commit: 8e65320d Merge tag 'drm-fixes-2026-06-06' of https://g..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=11f57166580000
kernel config: https://syzkaller.appspot.com/x/.config?x=8118209836970b54
dashboard link: https://syzkaller.appspot.com/bug?extid=f6fdb3bdd2c1d419e263
compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
patch: https://syzkaller.appspot.com/x/patch.diff?x=1705eb7e580000

Hillf Danton

unread,
5:41 PM (5 hours ago) 5:41 PM
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
> Date: Sat, 06 Jun 2026 04:35:28 -0700 [thread overview]
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: ba3e43a9e601 Merge tag 'soc-fixes-7.1-2' of git://git.kern..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=12b65a86580000
> kernel config: https://syzkaller.appspot.com/x/.config?x=8118209836970b54
> dashboard link: https://syzkaller.appspot.com/bug?extid=f6fdb3bdd2c1d419e263
> compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=158b5f2e580000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13d47dd2580000

--- x/net/9p/trans_virtio.c
+++ y/net/9p/trans_virtio.c
@@ -298,6 +298,7 @@ req_retry:
return -EIO;
}
}
+ p9_req_get(req);
virtqueue_kick(chan->vq);
spin_unlock_irqrestore(&chan->lock, flags);

--

syzbot

unread,
6:08 PM (5 hours ago) 6:08 PM
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+f6fdb3...@syzkaller.appspotmail.com
Tested-by: syzbot+f6fdb3...@syzkaller.appspotmail.com

Tested on:

commit: 8e65320d Merge tag 'drm-fixes-2026-06-06' of https://g..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=134ee1b6580000
kernel config: https://syzkaller.appspot.com/x/.config?x=8118209836970b54
dashboard link: https://syzkaller.appspot.com/bug?extid=f6fdb3bdd2c1d419e263
compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
patch: https://syzkaller.appspot.com/x/patch.diff?x=146fd173980000

Note: testing is done by a robot and is best-effort only.
Reply all
Reply to author
Forward
0 new messages