[syzbot] [netfs?] WARNING: refcount bug in netfs_put_subrequest

7 views
Skip to first unread message

syzbot

unread,
Feb 14, 2025, 1:39:28 AM2/14/25
to dhow...@redhat.com, jla...@kernel.org, linux-...@vger.kernel.org, linux-...@vger.kernel.org, ne...@lists.linux.dev, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 69b54314c975 Merge tag 'kbuild-fixes-v6.14' of git://git.k..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=106d6bdf980000
kernel config: https://syzkaller.appspot.com/x/.config?x=a7ddf49cf33ba213
dashboard link: https://syzkaller.appspot.com/bug?extid=d9890527385ab9767e03
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13aafdf8580000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/7feb34a89c2a/non_bootable_disk-69b54314.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/2d0a58d1d655/vmlinux-69b54314.xz
kernel image: https://storage.googleapis.com/syzbot-assets/b99949b40299/bzImage-69b54314.xz

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

netfs: Couldn't get user pages (rc=-14)
------------[ cut here ]------------
refcount_t: underflow; use-after-free.
WARNING: CPU: 3 PID: 6306 at lib/refcount.c:28 refcount_warn_saturate+0x14a/0x210 lib/refcount.c:28
Modules linked in:
CPU: 3 UID: 0 PID: 6306 Comm: syz.2.100 Not tainted 6.14.0-rc1-syzkaller-00276-g69b54314c975 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
RIP: 0010:refcount_warn_saturate+0x14a/0x210 lib/refcount.c:28
Code: ff 89 de e8 78 71 f5 fc 84 db 0f 85 66 ff ff ff e8 cb 76 f5 fc c6 05 e5 68 86 0b 01 90 48 c7 c7 00 fb d2 8b e8 97 b2 b5 fc 90 <0f> 0b 90 90 e9 43 ff ff ff e8 a8 76 f5 fc 0f b6 1d c0 68 86 0b 31
RSP: 0018:ffffc900030d7750 EFLAGS: 00010286
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff817a1159
RDX: ffff88805135c880 RSI: ffffffff817a1166 RDI: 0000000000000001
RBP: ffff88802d916fa0 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000005
R13: 000000000000006f R14: 0000000000000001 R15: ffff88802d916fa0
FS: 00007fee79bce6c0(0000) GS:ffff88806a900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fee79bad000 CR3: 00000000233ec000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
__refcount_sub_and_test include/linux/refcount.h:275 [inline]
__refcount_dec_and_test include/linux/refcount.h:307 [inline]
netfs_put_subrequest+0x2c1/0x4d0 fs/netfs/objects.c:230
netfs_collect_read_results fs/netfs/read_collect.c:300 [inline]
netfs_read_collection+0x25af/0x3cb0 fs/netfs/read_collect.c:417
netfs_wait_for_pause+0x31c/0x3e0 fs/netfs/read_collect.c:689
netfs_dispatch_unbuffered_reads fs/netfs/direct_read.c:106 [inline]
netfs_unbuffered_read fs/netfs/direct_read.c:144 [inline]
netfs_unbuffered_read_iter_locked+0xb50/0x1610 fs/netfs/direct_read.c:229
netfs_unbuffered_read_iter+0xc5/0x100 fs/netfs/direct_read.c:264
v9fs_file_read_iter+0xbf/0x100 fs/9p/vfs_file.c:361
aio_read+0x313/0x4e0 fs/aio.c:1602
__io_submit_one fs/aio.c:2003 [inline]
io_submit_one+0x1580/0x1da0 fs/aio.c:2052
__do_sys_io_submit fs/aio.c:2111 [inline]
__se_sys_io_submit fs/aio.c:2081 [inline]
__x64_sys_io_submit+0x1b2/0x340 fs/aio.c:2081
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fee78d8cde9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fee79bce038 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1
RAX: ffffffffffffffda RBX: 00007fee78fa5fa0 RCX: 00007fee78d8cde9
RDX: 00004000000002c0 RSI: 0000000000000001 RDI: 00007fee79bad000
RBP: 00007fee78e0e2a0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fee78fa5fa0 R15: 00007ffe1e525b98
</TASK>


---
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,
Feb 14, 2025, 6:19:50 AM2/14/25
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Thu, 13 Feb 2025 22:39:25 -0800
> syzbot found the following issue on:
>
> HEAD commit: 69b54314c975 Merge tag 'kbuild-fixes-v6.14' of git://git.k..
> git tree: upstream
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13aafdf8580000

#syz test upstream master

--- x/fs/netfs/read_collect.c
+++ y/fs/netfs/read_collect.c
@@ -289,6 +289,10 @@ reassess:
/* Remove if completely consumed. */
stream->source = front->source;
spin_lock(&rreq->lock);
+ if (front != stream->front) {
+ spin_unlock(&rreq->lock);
+ goto reassess;
+ }

remove = front;
trace_netfs_sreq(front, netfs_sreq_trace_discard);
--

syzbot

unread,
Feb 14, 2025, 6:42:04 AM2/14/25
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:
KASAN: slab-use-after-free Write in io_submit_one

netfs: Couldn't get user pages (rc=-14)
==================================================================
BUG: KASAN: slab-use-after-free in instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
BUG: KASAN: slab-use-after-free in atomic_fetch_sub_release include/linux/atomic/atomic-instrumented.h:400 [inline]
BUG: KASAN: slab-use-after-free in __refcount_sub_and_test include/linux/refcount.h:264 [inline]
BUG: KASAN: slab-use-after-free in __refcount_dec_and_test include/linux/refcount.h:307 [inline]
BUG: KASAN: slab-use-after-free in refcount_dec_and_test include/linux/refcount.h:325 [inline]
BUG: KASAN: slab-use-after-free in iocb_put fs/aio.c:1208 [inline]
BUG: KASAN: slab-use-after-free in io_submit_one+0x4e5/0x1da0 fs/aio.c:2055
Write of size 4 at addr ffff88802e13ae88 by task syz.1.40/6596

CPU: 3 UID: 0 PID: 6596 Comm: syz.1.40 Not tainted 6.14.0-rc2-syzkaller-g128c8f96eb86-dirty #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0xc3/0x620 mm/kasan/report.c:489
kasan_report+0xd9/0x110 mm/kasan/report.c:602
check_region_inline mm/kasan/generic.c:183 [inline]
kasan_check_range+0xef/0x1a0 mm/kasan/generic.c:189
instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
atomic_fetch_sub_release include/linux/atomic/atomic-instrumented.h:400 [inline]
__refcount_sub_and_test include/linux/refcount.h:264 [inline]
__refcount_dec_and_test include/linux/refcount.h:307 [inline]
refcount_dec_and_test include/linux/refcount.h:325 [inline]
iocb_put fs/aio.c:1208 [inline]
io_submit_one+0x4e5/0x1da0 fs/aio.c:2055
__do_sys_io_submit fs/aio.c:2111 [inline]
__se_sys_io_submit fs/aio.c:2081 [inline]
__x64_sys_io_submit+0x1b2/0x340 fs/aio.c:2081
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f8f53d8cde9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f8f54b7f038 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1
RAX: ffffffffffffffda RBX: 00007f8f53fa5fa0 RCX: 00007f8f53d8cde9
RDX: 00004000000002c0 RSI: 0000000000000001 RDI: 00007f8f54b5e000
RBP: 00007f8f53e0e2a0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f8f53fa5fa0 R15: 00007ffeeb0594c8
</TASK>

Allocated by task 6596:
kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
kasan_save_track+0x14/0x30 mm/kasan/common.c:68
unpoison_slab_object mm/kasan/common.c:319 [inline]
__kasan_slab_alloc+0x89/0x90 mm/kasan/common.c:345
kasan_slab_alloc include/linux/kasan.h:250 [inline]
slab_post_alloc_hook mm/slub.c:4115 [inline]
slab_alloc_node mm/slub.c:4164 [inline]
kmem_cache_alloc_noprof+0x226/0x3d0 mm/slub.c:4171
aio_get_req fs/aio.c:1058 [inline]
io_submit_one+0x123/0x1da0 fs/aio.c:2048
__do_sys_io_submit fs/aio.c:2111 [inline]
__se_sys_io_submit fs/aio.c:2081 [inline]
__x64_sys_io_submit+0x1b2/0x340 fs/aio.c:2081
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 6596:
kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
kasan_save_track+0x14/0x30 mm/kasan/common.c:68
kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:576
poison_slab_object mm/kasan/common.c:247 [inline]
__kasan_slab_free+0x51/0x70 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:4609 [inline]
kmem_cache_free+0x2e2/0x4d0 mm/slub.c:4711
iocb_destroy fs/aio.c:1110 [inline]
iocb_put fs/aio.c:1210 [inline]
iocb_put fs/aio.c:1206 [inline]
aio_complete_rw+0x3ec/0x7b0 fs/aio.c:1507
netfs_rreq_assess_dio fs/netfs/read_collect.c:379 [inline]
netfs_read_collection+0x30fa/0x3cf0 fs/netfs/read_collect.c:442
netfs_wait_for_pause+0x31c/0x3e0 fs/netfs/read_collect.c:693
netfs_dispatch_unbuffered_reads fs/netfs/direct_read.c:106 [inline]
netfs_unbuffered_read fs/netfs/direct_read.c:144 [inline]
netfs_unbuffered_read_iter_locked+0xb50/0x1610 fs/netfs/direct_read.c:229
netfs_unbuffered_read_iter+0xc5/0x100 fs/netfs/direct_read.c:264
v9fs_file_read_iter+0xbf/0x100 fs/9p/vfs_file.c:361
aio_read+0x313/0x4e0 fs/aio.c:1602
__io_submit_one fs/aio.c:2003 [inline]
io_submit_one+0x1580/0x1da0 fs/aio.c:2052
__do_sys_io_submit fs/aio.c:2111 [inline]
__se_sys_io_submit fs/aio.c:2081 [inline]
__x64_sys_io_submit+0x1b2/0x340 fs/aio.c:2081
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff88802e13adc0
which belongs to the cache aio_kiocb of size 216
The buggy address is located 200 bytes inside of
freed 216-byte region [ffff88802e13adc0, ffff88802e13ae98)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff88802e13af00 pfn:0x2e13a
head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff888020025cc0 dead000000000122 0000000000000000
raw: ffff88802e13af00 0000000080190010 00000000f5000000 0000000000000000
head: 00fff00000000040 ffff888020025cc0 dead000000000122 0000000000000000
head: ffff88802e13af00 0000000080190010 00000000f5000000 0000000000000000
head: 00fff00000000001 ffffea0000b84e81 ffffffffffffffff 0000000000000000
head: 0000000000000002 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 6485, tgid 6484 (syz.1.20), ts 73097474485, free_ts 73096375881
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x181/0x1b0 mm/page_alloc.c:1551
prep_new_page mm/page_alloc.c:1559 [inline]
get_page_from_freelist+0xfce/0x2f80 mm/page_alloc.c:3477
__alloc_frozen_pages_noprof+0x221/0x2470 mm/page_alloc.c:4739
alloc_pages_mpol+0x1fc/0x540 mm/mempolicy.c:2270
alloc_slab_page mm/slub.c:2423 [inline]
allocate_slab mm/slub.c:2587 [inline]
new_slab+0x23d/0x330 mm/slub.c:2640
___slab_alloc+0xc5d/0x1720 mm/slub.c:3826
__slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3916
__slab_alloc_node mm/slub.c:3991 [inline]
slab_alloc_node mm/slub.c:4152 [inline]
kmem_cache_alloc_noprof+0xfa/0x3d0 mm/slub.c:4171
aio_get_req fs/aio.c:1058 [inline]
io_submit_one+0x123/0x1da0 fs/aio.c:2048
__do_sys_io_submit fs/aio.c:2111 [inline]
__se_sys_io_submit fs/aio.c:2081 [inline]
__x64_sys_io_submit+0x1b2/0x340 fs/aio.c:2081
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
page last free pid 34 tgid 34 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
free_pages_prepare mm/page_alloc.c:1127 [inline]
free_frozen_pages+0x6db/0xfb0 mm/page_alloc.c:2660
rcu_do_batch kernel/rcu/tree.c:2546 [inline]
rcu_core+0x79d/0x14d0 kernel/rcu/tree.c:2802
handle_softirqs+0x213/0x8f0 kernel/softirq.c:561
run_ksoftirqd kernel/softirq.c:950 [inline]
run_ksoftirqd+0x3a/0x60 kernel/softirq.c:942
smpboot_thread_fn+0x661/0xa30 kernel/smpboot.c:164
kthread+0x3af/0x750 kernel/kthread.c:464
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:148
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Memory state around the buggy address:
ffff88802e13ad80: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
ffff88802e13ae00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88802e13ae80: fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc
^
ffff88802e13af00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88802e13af80: fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc fc
==================================================================


Tested on:

commit: 128c8f96 Merge tag 'drm-fixes-2025-02-14' of https://g..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17c659b0580000
kernel config: https://syzkaller.appspot.com/x/.config?x=c09dc55ba7f798e3
dashboard link: https://syzkaller.appspot.com/bug?extid=d9890527385ab9767e03
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=102087df980000

Hillf Danton

unread,
Feb 14, 2025, 6:14:13 PM2/14/25
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Thu, 13 Feb 2025 22:39:25 -0800
> syzbot found the following issue on:
>
> HEAD commit: 69b54314c975 Merge tag 'kbuild-fixes-v6.14' of git://git.k..
> git tree: upstream
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13aafdf8580000

#syz test upstream master

--- x/fs/netfs/read_collect.c
+++ y/fs/netfs/read_collect.c
@@ -289,6 +289,10 @@ reassess:
/* Remove if completely consumed. */
stream->source = front->source;
spin_lock(&rreq->lock);
+ if (front != stream->front) {
+ spin_unlock(&rreq->lock);
+ goto reassess;
+ }

remove = front;
trace_netfs_sreq(front, netfs_sreq_trace_discard);
@@ -345,6 +349,7 @@ static void netfs_rreq_assess_dio(struct
struct netfs_io_subrequest *subreq;
struct netfs_io_stream *stream = &rreq->io_streams[0];
unsigned int i;
+ struct kiocb *iocb = NULL;

/* Collect unbuffered reads and direct reads, adding up the transfer
* sizes until we find the first short or failed subrequest.
@@ -369,12 +374,16 @@ static void netfs_rreq_assess_dio(struct
}
}

+ spin_lock(&rreq->lock);
if (rreq->iocb) {
rreq->iocb->ki_pos += rreq->transferred;
if (rreq->iocb->ki_complete)
- rreq->iocb->ki_complete(
- rreq->iocb, rreq->error ? rreq->error : rreq->transferred);
+ iocb = rreq->iocb;
+ rreq->iocb = NULL;
}
+ spin_unlock(&rreq->lock);
+ if (iocb)
+ iocb->ki_complete(iocb, rreq->error ? rreq->error : rreq->transferred);
if (rreq->netfs_ops->done)
rreq->netfs_ops->done(rreq);
if (rreq->origin == NETFS_DIO_READ)
--

syzbot

unread,
Feb 14, 2025, 6:52:05 PM2/14/25
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+d98905...@syzkaller.appspotmail.com
Tested-by: syzbot+d98905...@syzkaller.appspotmail.com

Tested on:

commit: cabb162e Merge tag 'v6.14-rc2-smb3-client-fixes' of gi..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=14024f18580000
kernel config: https://syzkaller.appspot.com/x/.config?x=c09dc55ba7f798e3
dashboard link: https://syzkaller.appspot.com/bug?extid=d9890527385ab9767e03
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=11a867df980000

Note: testing is done by a robot and is best-effort only.

syzbot

unread,
May 21, 2025, 2:31:18 AM5/21/25
to syzkall...@googlegroups.com
Auto-closing this bug as obsolete.
No recent activity, existing reproducers are no longer triggering the issue.
Reply all
Reply to author
Forward
0 new messages