[syzbot] [netfs?] KASAN: slab-use-after-free Read in netfs_unbuffered_write

6 views
Skip to first unread message

syzbot

unread,
May 29, 2026, 4:01:31 PM (10 days ago) May 29
to dhow...@redhat.com, linux-...@vger.kernel.org, linux-...@vger.kernel.org, ne...@lists.linux.dev, p...@manguebit.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 8fde5d1d47f6 Merge tag 'acpi-7.1-rc6' of git://git.kernel...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=107a02b6580000
kernel config: https://syzkaller.appspot.com/x/.config?x=8118209836970b54
dashboard link: https://syzkaller.appspot.com/bug?extid=3c74b1f0c372e98efc32
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=15bedcb6580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=171b697e580000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/d900f083ada3/non_bootable_disk-8fde5d1d.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/529080512bd5/vmlinux-8fde5d1d.xz
kernel image: https://storage.googleapis.com/syzbot-assets/39c09b74f46c/bzImage-8fde5d1d.xz

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

==================================================================
BUG: KASAN: slab-use-after-free in netfs_unbuffered_write+0x1c21/0x21e0 fs/netfs/direct_write.c:119
Read of size 2 at addr ffff888022e87864 by task syz.0.17/5936

CPU: 1 UID: 0 PID: 5936 Comm: syz.0.17 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
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0x13d/0x4b0 mm/kasan/report.c:482
kasan_report+0xdf/0x1d0 mm/kasan/report.c:595
netfs_unbuffered_write+0x1c21/0x21e0 fs/netfs/direct_write.c:119
netfs_unbuffered_write_iter_locked+0x7e2/0xa90 fs/netfs/direct_write.c:294
netfs_unbuffered_write_iter+0x442/0x740 fs/netfs/direct_write.c:386
v9fs_file_write_iter+0xbf/0x100 fs/9p/vfs_file.c:409
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x6ac/0x1070 fs/read_write.c:688
ksys_write+0x12a/0x250 fs/read_write.c:740
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x115/0x870 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f2eecd9ce59
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 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 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f2eedc49028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f2eed015fa0 RCX: 00007f2eecd9ce59
RDX: 00000000fffffdd8 RSI: 0000200000000540 RDI: 0000000000000003
RBP: 00007f2eece32d6f R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f2eed016038 R14: 00007f2eed015fa0 R15: 00007fff0ed7a0b8
</TASK>

Allocated by task 5936:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
unpoison_slab_object mm/kasan/common.c:340 [inline]
__kasan_slab_alloc+0x89/0x90 mm/kasan/common.c:366
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4570 [inline]
slab_alloc_node mm/slub.c:4899 [inline]
kmem_cache_alloc_noprof+0x241/0x6e0 mm/slub.c:4906
mempool_alloc_noprof+0x1b7/0x310 mm/mempool.c:566
netfs_alloc_subrequest+0xc1/0x3c0 fs/netfs/objects.c:204
netfs_prepare_write+0x76/0x780 fs/netfs/write_issue.c:172
netfs_unbuffered_write+0x7b8/0x21e0 fs/netfs/direct_write.c:111
netfs_unbuffered_write_iter_locked+0x7e2/0xa90 fs/netfs/direct_write.c:294
netfs_unbuffered_write_iter+0x442/0x740 fs/netfs/direct_write.c:386
v9fs_file_write_iter+0xbf/0x100 fs/9p/vfs_file.c:409
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x6ac/0x1070 fs/read_write.c:688
ksys_write+0x12a/0x250 fs/read_write.c:740
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x115/0x870 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 5936:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
kasan_save_free_info+0x3b/0x70 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5f/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2689 [inline]
slab_free mm/slub.c:6251 [inline]
kmem_cache_free+0x127/0x6c0 mm/slub.c:6378
mempool_free+0xde/0x130 mm/mempool.c:711
netfs_free_subrequest fs/netfs/objects.c:239 [inline]
netfs_put_subrequest+0x282/0x4c0 fs/netfs/objects.c:255
netfs_unbuffered_write+0x13ed/0x21e0 fs/netfs/direct_write.c:118
netfs_unbuffered_write_iter_locked+0x7e2/0xa90 fs/netfs/direct_write.c:294
netfs_unbuffered_write_iter+0x442/0x740 fs/netfs/direct_write.c:386
v9fs_file_write_iter+0xbf/0x100 fs/9p/vfs_file.c:409
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x6ac/0x1070 fs/read_write.c:688
ksys_write+0x12a/0x250 fs/read_write.c:740
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x115/0x870 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff888022e877c0
which belongs to the cache netfs_subrequest of size 200
The buggy address is located 164 bytes inside of
freed 200-byte region [ffff888022e877c0, ffff888022e87888)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x22e86
head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
memcg:ffff888026b62001
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88801fab5680 dead000000000100 dead000000000122
raw: 0000000000000000 0000000800190019 00000000f5000000 ffff888026b62001
head: 00fff00000000040 ffff88801fab5680 dead000000000100 dead000000000122
head: 0000000000000000 0000000800190019 00000000f5000000 ffff888026b62001
head: 00fff00000000001 ffffffffffffff81 00000000ffffffff 00000000ffffffff
head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000002
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 1, tgid 1 (swapper/0), ts 4032896346, free_ts 0
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1853
prep_new_page mm/page_alloc.c:1861 [inline]
get_page_from_freelist+0x11a6/0x3410 mm/page_alloc.c:3941
__alloc_frozen_pages_noprof+0x27c/0x2bc0 mm/page_alloc.c:5221
alloc_slab_page mm/slub.c:3278 [inline]
allocate_slab mm/slub.c:3467 [inline]
new_slab+0xa6/0x6c0 mm/slub.c:3525
refill_objects+0x277/0x420 mm/slub.c:7272
refill_sheaf mm/slub.c:2816 [inline]
__pcs_replace_empty_main+0x375/0x650 mm/slub.c:4652
alloc_from_pcs mm/slub.c:4750 [inline]
slab_alloc_node mm/slub.c:4884 [inline]
kmem_cache_alloc_noprof+0x480/0x6e0 mm/slub.c:4906
mempool_init_node+0x2f7/0x6e0 mm/mempool.c:259
mempool_init_noprof+0x3a/0x50 mm/mempool.c:289
netfs_init+0x16c/0x2b0 fs/netfs/main.c:128
do_one_initcall+0x121/0x750 init/main.c:1392
do_initcall_level init/main.c:1454 [inline]
do_initcalls init/main.c:1470 [inline]
do_basic_setup init/main.c:1490 [inline]
kernel_init_freeable+0x6ea/0x7b0 init/main.c:1703
kernel_init+0x1f/0x1e0 init/main.c:1593
ret_from_fork+0x72b/0xd50 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
page_owner free stack trace missing

Memory state around the buggy address:
ffff888022e87700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888022e87780: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
>ffff888022e87800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888022e87880: fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888022e87900: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


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

syzbot

unread,
May 29, 2026, 10:13:31 PM (10 days ago) May 29
to linux-...@vger.kernel.org, syzkall...@googlegroups.com
For archival purposes, forwarding an incoming command email to
linux-...@vger.kernel.org, syzkall...@googlegroups.com.

***

Subject: #syz test
Author: hon...@uniontech.com

From 57d3537f407aaf4229abc9b78513c6222cbfb799 Mon Sep 17 00:00:00 2001
From: hongao <hon...@uniontech.com>
Date: Sat, 30 May 2026 09:08:24 +0800
Subject: [PATCH] netfs: Fix UAF in netfs_unbuffered_write() on failed
preparation

#syz test

If write subrequest preparation fails, netfs_unbuffered_write() calls
netfs_write_subrequest_terminated() and then reads subreq->error to set
wreq->error.

However, netfs_write_subrequest_terminated() consumes a reference to the
subrequest through netfs_put_subrequest(), so the subrequest may be freed
before netfs_unbuffered_write() reads subreq->error again. This can
trigger a slab-use-after-free.

Save the error locally before terminating the subrequest, and use the
saved value afterwards.

Fixes: a0b4c7a49137 ("netfs: Fix unbuffered/DIO writes to dispatch subrequests in strict sequence")
Reported-by: syzbot+3c74b1...@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=3c74b1f0c372e98efc32

Signed-off-by: hongao <hon...@uniontech.com>
---
fs/netfs/direct_write.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/netfs/direct_write.c b/fs/netfs/direct_write.c
index 25f8ceb15fad..2d5361702076 100644
--- a/fs/netfs/direct_write.c
+++ b/fs/netfs/direct_write.c
@@ -115,8 +115,9 @@ static int netfs_unbuffered_write(struct netfs_io_request *wreq)

/* Check if (re-)preparation failed. */
if (unlikely(test_bit(NETFS_SREQ_FAILED, &subreq->flags))) {
- netfs_write_subrequest_terminated(subreq, subreq->error);
- wreq->error = subreq->error;
+ ret = subreq->error;
+ wreq->error = ret;
+ netfs_write_subrequest_terminated(subreq, ret);
break;
}

--
2.51.0

syzbot

unread,
May 29, 2026, 10:36:04 PM (10 days ago) May 29
to hon...@uniontech.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 Read in netfs_clear_subrequests

==================================================================
BUG: KASAN: slab-use-after-free in __list_del_entry_valid_or_report+0x18a/0x1d0 lib/list_debug.c:49
Read of size 8 at addr ffff888023e99598 by task syz.0.17/6261

CPU: 0 UID: 0 PID: 6261 Comm: syz.0.17 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
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0x13d/0x4b0 mm/kasan/report.c:482
kasan_report+0xdf/0x1d0 mm/kasan/report.c:595
__list_del_entry_valid_or_report+0x18a/0x1d0 lib/list_debug.c:49
__list_del_entry_valid include/linux/list.h:132 [inline]
__list_del_entry include/linux/list.h:246 [inline]
list_del include/linux/list.h:260 [inline]
netfs_clear_subrequests+0x98/0x260 fs/netfs/objects.c:105
netfs_unbuffered_write_done fs/netfs/direct_write.c:59 [inline]
netfs_unbuffered_write+0x1358/0x21b0 fs/netfs/direct_write.c:203
netfs_unbuffered_write_iter_locked+0x7e2/0xa90 fs/netfs/direct_write.c:295
netfs_unbuffered_write_iter+0x442/0x740 fs/netfs/direct_write.c:387
v9fs_file_write_iter+0xbf/0x100 fs/9p/vfs_file.c:409
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x6ac/0x1070 fs/read_write.c:688
ksys_write+0x12a/0x250 fs/read_write.c:740
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x115/0x870 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f85f8d9ce59
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 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 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f85f9c79028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f85f9015fa0 RCX: 00007f85f8d9ce59
RDX: 00000000fffffdd8 RSI: 0000200000000540 RDI: 0000000000000003
RBP: 00007f85f8e32d6f R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f85f9016038 R14: 00007f85f9015fa0 R15: 00007ffd265d5168
</TASK>

Allocated by task 6261:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
unpoison_slab_object mm/kasan/common.c:340 [inline]
__kasan_slab_alloc+0x89/0x90 mm/kasan/common.c:366
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4570 [inline]
slab_alloc_node mm/slub.c:4899 [inline]
kmem_cache_alloc_noprof+0x241/0x6e0 mm/slub.c:4906
mempool_alloc_noprof+0x1b7/0x310 mm/mempool.c:566
netfs_alloc_subrequest+0xc1/0x3c0 fs/netfs/objects.c:204
netfs_prepare_write+0x76/0x780 fs/netfs/write_issue.c:172
netfs_unbuffered_write+0x7b8/0x21b0 fs/netfs/direct_write.c:111
netfs_unbuffered_write_iter_locked+0x7e2/0xa90 fs/netfs/direct_write.c:295
netfs_unbuffered_write_iter+0x442/0x740 fs/netfs/direct_write.c:387
v9fs_file_write_iter+0xbf/0x100 fs/9p/vfs_file.c:409
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x6ac/0x1070 fs/read_write.c:688
ksys_write+0x12a/0x250 fs/read_write.c:740
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x115/0x870 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 6261:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
kasan_save_free_info+0x3b/0x70 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5f/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2689 [inline]
slab_free mm/slub.c:6251 [inline]
kmem_cache_free+0x127/0x6c0 mm/slub.c:6378
mempool_free+0xde/0x130 mm/mempool.c:711
netfs_free_subrequest fs/netfs/objects.c:239 [inline]
netfs_put_subrequest+0x282/0x4c0 fs/netfs/objects.c:255
netfs_unbuffered_write+0x1419/0x21b0 fs/netfs/direct_write.c:120
netfs_unbuffered_write_iter_locked+0x7e2/0xa90 fs/netfs/direct_write.c:295
netfs_unbuffered_write_iter+0x442/0x740 fs/netfs/direct_write.c:387
v9fs_file_write_iter+0xbf/0x100 fs/9p/vfs_file.c:409
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x6ac/0x1070 fs/read_write.c:688
ksys_write+0x12a/0x250 fs/read_write.c:740
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x115/0x870 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff888023e99540
which belongs to the cache netfs_subrequest of size 200
The buggy address is located 88 bytes inside of
freed 200-byte region [ffff888023e99540, ffff888023e99608)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff888023e99680 pfn:0x23e98
head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
memcg:ffff888023e980d9
flags: 0xfff00000000240(workingset|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000240 ffff888100ae5680 ffff888022d29408 ffff888022d29408
raw: ffff888023e99680 0000014000190012 00000000f5000000 ffff888023e980d9
head: 00fff00000000240 ffff888100ae5680 ffff888022d29408 ffff888022d29408
head: ffff888023e99680 0000014000190012 00000000f5000000 ffff888023e980d9
head: 00fff00000000001 ffffffffffffff81 00000000ffffffff 00000000ffffffff
head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000002
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0xd2880(GFP_NOWAIT|__GFP_FS|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 6261, tgid 6260 (syz.0.17), ts 105932466205, free_ts 105884430549
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1853
prep_new_page mm/page_alloc.c:1861 [inline]
get_page_from_freelist+0x11a6/0x3410 mm/page_alloc.c:3941
__alloc_frozen_pages_noprof+0x27c/0x2bc0 mm/page_alloc.c:5221
alloc_slab_page mm/slub.c:3278 [inline]
allocate_slab mm/slub.c:3467 [inline]
new_slab+0xa6/0x6c0 mm/slub.c:3525
refill_objects+0x277/0x420 mm/slub.c:7272
refill_sheaf mm/slub.c:2816 [inline]
__pcs_replace_empty_main+0x375/0x650 mm/slub.c:4652
alloc_from_pcs mm/slub.c:4750 [inline]
slab_alloc_node mm/slub.c:4884 [inline]
kmem_cache_alloc_noprof+0x480/0x6e0 mm/slub.c:4906
mempool_alloc_noprof+0x1b7/0x310 mm/mempool.c:566
netfs_alloc_subrequest+0xc1/0x3c0 fs/netfs/objects.c:204
netfs_prepare_write+0x76/0x780 fs/netfs/write_issue.c:172
netfs_unbuffered_write+0x7b8/0x21b0 fs/netfs/direct_write.c:111
netfs_unbuffered_write_iter_locked+0x7e2/0xa90 fs/netfs/direct_write.c:295
netfs_unbuffered_write_iter+0x442/0x740 fs/netfs/direct_write.c:387
v9fs_file_write_iter+0xbf/0x100 fs/9p/vfs_file.c:409
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x6ac/0x1070 fs/read_write.c:688
ksys_write+0x12a/0x250 fs/read_write.c:740
page last free pid 40 tgid 40 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
__free_pages_prepare mm/page_alloc.c:1397 [inline]
__free_frozen_pages+0x794/0x10a0 mm/page_alloc.c:2938
rcu_do_batch kernel/rcu/tree.c:2617 [inline]
rcu_core+0x5a2/0x10d0 kernel/rcu/tree.c:2869
handle_softirqs+0x1ea/0xa00 kernel/softirq.c:622
__do_softirq kernel/softirq.c:656 [inline]
invoke_softirq kernel/softirq.c:496 [inline]
__irq_exit_rcu+0x162/0x210 kernel/softirq.c:735
irq_exit_rcu+0x9/0x30 kernel/softirq.c:752
instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1061 [inline]
sysvec_apic_timer_interrupt+0xa3/0xc0 arch/x86/kernel/apic/apic.c:1061
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:697

Memory state around the buggy address:
ffff888023e99480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888023e99500: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
>ffff888023e99580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888023e99600: fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888023e99680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================


Tested on:

commit: f5e5d350 Merge tag 'spi-fix-v7.1-rc5' of git://git.ker..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1406497e580000
kernel config: https://syzkaller.appspot.com/x/.config?x=8118209836970b54
dashboard link: https://syzkaller.appspot.com/bug?extid=3c74b1f0c372e98efc32
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=14be29ec580000

Edward Adam Davis

unread,
May 30, 2026, 11:44:39 PM (9 days ago) May 30
to syzbot+3c74b1...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
#syz test

diff --git a/fs/netfs/direct_write.c b/fs/netfs/direct_write.c
index 25f8ceb15fad..697648214cf0 100644
--- a/fs/netfs/direct_write.c
+++ b/fs/netfs/direct_write.c
@@ -115,8 +115,8 @@ static int netfs_unbuffered_write(struct netfs_io_request *wreq)

/* Check if (re-)preparation failed. */
if (unlikely(test_bit(NETFS_SREQ_FAILED, &subreq->flags))) {
- netfs_write_subrequest_terminated(subreq, subreq->error);
wreq->error = subreq->error;
+ netfs_write_subrequest_terminated(subreq, subreq->error);
break;
}


syzbot

unread,
May 31, 2026, 12:04:04 AM (9 days ago) May 31
to ead...@qq.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 Read in netfs_clear_subrequests

==================================================================
BUG: KASAN: slab-use-after-free in __list_del_entry_valid_or_report+0x18a/0x1d0 lib/list_debug.c:49
Read of size 8 at addr ffff888028092f58 by task syz.0.17/6267

CPU: 3 UID: 0 PID: 6267 Comm: syz.0.17 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
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0x13d/0x4b0 mm/kasan/report.c:482
kasan_report+0xdf/0x1d0 mm/kasan/report.c:595
__list_del_entry_valid_or_report+0x18a/0x1d0 lib/list_debug.c:49
__list_del_entry_valid include/linux/list.h:132 [inline]
__list_del_entry include/linux/list.h:246 [inline]
list_del include/linux/list.h:260 [inline]
netfs_clear_subrequests+0x98/0x260 fs/netfs/objects.c:105
netfs_unbuffered_write_done fs/netfs/direct_write.c:59 [inline]
netfs_unbuffered_write+0x1358/0x21a0 fs/netfs/direct_write.c:202
netfs_unbuffered_write_iter_locked+0x7e2/0xa90 fs/netfs/direct_write.c:294
netfs_unbuffered_write_iter+0x442/0x740 fs/netfs/direct_write.c:386
v9fs_file_write_iter+0xbf/0x100 fs/9p/vfs_file.c:409
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x6ac/0x1070 fs/read_write.c:688
ksys_write+0x12a/0x250 fs/read_write.c:740
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x115/0x870 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fbdafd9ce59
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 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 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fbdb0bf8028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fbdb0015fa0 RCX: 00007fbdafd9ce59
RDX: 00000000fffffdd8 RSI: 0000200000000540 RDI: 0000000000000003
RBP: 00007fbdafe32d6f R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fbdb0016038 R14: 00007fbdb0015fa0 R15: 00007ffe0da23988
</TASK>

Allocated by task 6267:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
unpoison_slab_object mm/kasan/common.c:340 [inline]
__kasan_slab_alloc+0x89/0x90 mm/kasan/common.c:366
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4570 [inline]
slab_alloc_node mm/slub.c:4899 [inline]
kmem_cache_alloc_noprof+0x241/0x6e0 mm/slub.c:4906
mempool_alloc_noprof+0x1b7/0x310 mm/mempool.c:566
netfs_alloc_subrequest+0xc1/0x3c0 fs/netfs/objects.c:204
netfs_prepare_write+0x76/0x780 fs/netfs/write_issue.c:172
netfs_unbuffered_write+0x7b8/0x21a0 fs/netfs/direct_write.c:111
netfs_unbuffered_write_iter_locked+0x7e2/0xa90 fs/netfs/direct_write.c:294
netfs_unbuffered_write_iter+0x442/0x740 fs/netfs/direct_write.c:386
v9fs_file_write_iter+0xbf/0x100 fs/9p/vfs_file.c:409
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x6ac/0x1070 fs/read_write.c:688
ksys_write+0x12a/0x250 fs/read_write.c:740
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x115/0x870 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 6267:
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
kasan_save_free_info+0x3b/0x70 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5f/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2689 [inline]
slab_free mm/slub.c:6251 [inline]
kmem_cache_free+0x127/0x6c0 mm/slub.c:6378
mempool_free+0xde/0x130 mm/mempool.c:711
netfs_free_subrequest fs/netfs/objects.c:239 [inline]
netfs_put_subrequest+0x282/0x4c0 fs/netfs/objects.c:255
netfs_unbuffered_write+0x1420/0x21a0 fs/netfs/direct_write.c:119
netfs_unbuffered_write_iter_locked+0x7e2/0xa90 fs/netfs/direct_write.c:294
netfs_unbuffered_write_iter+0x442/0x740 fs/netfs/direct_write.c:386
v9fs_file_write_iter+0xbf/0x100 fs/9p/vfs_file.c:409
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x6ac/0x1070 fs/read_write.c:688
ksys_write+0x12a/0x250 fs/read_write.c:740
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x115/0x870 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff888028092f00
which belongs to the cache netfs_subrequest of size 200
The buggy address is located 88 bytes inside of
freed 200-byte region [ffff888028092f00, ffff888028092fc8)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff8880280932c0 pfn:0x28092
head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
memcg:ffff8880280920d9
flags: 0xfff00000000240(workingset|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000240 ffff88801fad1680 ffff888022be5408 ffff888022be5408
raw: ffff8880280932c0 000001400019000f 00000000f5000000 ffff8880280920d9
head: 00fff00000000240 ffff88801fad1680 ffff888022be5408 ffff888022be5408
head: ffff8880280932c0 000001400019000f 00000000f5000000 ffff8880280920d9
head: 00fff00000000001 ffffffffffffff81 00000000ffffffff 00000000ffffffff
head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000002
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0xd2880(GFP_NOWAIT|__GFP_FS|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 6267, tgid 6266 (syz.0.17), ts 103792298291, free_ts 103737337363
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1853
prep_new_page mm/page_alloc.c:1861 [inline]
get_page_from_freelist+0x11a6/0x3410 mm/page_alloc.c:3941
__alloc_frozen_pages_noprof+0x27c/0x2bc0 mm/page_alloc.c:5221
alloc_slab_page mm/slub.c:3278 [inline]
allocate_slab mm/slub.c:3467 [inline]
new_slab+0xa6/0x6c0 mm/slub.c:3525
refill_objects+0x277/0x420 mm/slub.c:7272
refill_sheaf mm/slub.c:2816 [inline]
__pcs_replace_empty_main+0x375/0x650 mm/slub.c:4652
alloc_from_pcs mm/slub.c:4750 [inline]
slab_alloc_node mm/slub.c:4884 [inline]
kmem_cache_alloc_noprof+0x480/0x6e0 mm/slub.c:4906
mempool_alloc_noprof+0x1b7/0x310 mm/mempool.c:566
netfs_alloc_subrequest+0xc1/0x3c0 fs/netfs/objects.c:204
netfs_prepare_write+0x76/0x780 fs/netfs/write_issue.c:172
netfs_unbuffered_write+0x7b8/0x21a0 fs/netfs/direct_write.c:111
netfs_unbuffered_write_iter_locked+0x7e2/0xa90 fs/netfs/direct_write.c:294
netfs_unbuffered_write_iter+0x442/0x740 fs/netfs/direct_write.c:386
v9fs_file_write_iter+0xbf/0x100 fs/9p/vfs_file.c:409
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x6ac/0x1070 fs/read_write.c:688
ksys_write+0x12a/0x250 fs/read_write.c:740
page last free pid 6266 tgid 6266 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
__free_pages_prepare mm/page_alloc.c:1397 [inline]
__free_frozen_pages+0x794/0x10a0 mm/page_alloc.c:2938
qlink_free mm/kasan/quarantine.c:163 [inline]
qlist_free_all+0x47/0xf0 mm/kasan/quarantine.c:179
kasan_quarantine_reduce+0x1a0/0x1f0 mm/kasan/quarantine.c:286
__kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:350
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4570 [inline]
slab_alloc_node mm/slub.c:4899 [inline]
__do_kmalloc_node mm/slub.c:5295 [inline]
__kmalloc_noprof+0x2b9/0x850 mm/slub.c:5308
kmalloc_noprof include/linux/slab.h:954 [inline]
tomoyo_realpath_from_path+0xb6/0x690 security/tomoyo/realpath.c:251
tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
tomoyo_check_open_permission+0x2af/0x3c0 security/tomoyo/file.c:776
tomoyo_file_open+0x6b/0x90 security/tomoyo/tomoyo.c:334
security_file_open+0xb5/0x1e0 security/security.c:2739
do_dentry_open+0x588/0x14d0 fs/open.c:924
vfs_open+0x82/0x3f0 fs/open.c:1079
do_open fs/namei.c:4699 [inline]
path_openat+0x208c/0x31a0 fs/namei.c:4858
do_file_open+0x20e/0x430 fs/namei.c:4887
do_sys_openat2+0x10d/0x1e0 fs/open.c:1364
do_sys_open fs/open.c:1370 [inline]
__do_sys_openat fs/open.c:1386 [inline]
__se_sys_openat fs/open.c:1381 [inline]
__x64_sys_openat+0x12d/0x210 fs/open.c:1381
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x115/0x870 arch/x86/entry/syscall_64.c:94

Memory state around the buggy address:
ffff888028092e00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888028092e80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888028092f00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888028092f80: fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc
ffff888028093000: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
==================================================================


Tested on:

commit: 174914ea Merge tag 'v7.1-rc6-smb3-client-fixes' of git..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=13f0c27a580000
kernel config: https://syzkaller.appspot.com/x/.config?x=8118209836970b54
dashboard link: https://syzkaller.appspot.com/bug?extid=3c74b1f0c372e98efc32
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=153097a6580000

Edward Adam Davis

unread,
May 31, 2026, 12:37:22 AM (9 days ago) May 31
to syzbot+3c74b1...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
#syz test

diff --git a/fs/netfs/direct_write.c b/fs/netfs/direct_write.c
index 25f8ceb15fad..8af58e4937c8 100644
--- a/fs/netfs/direct_write.c
+++ b/fs/netfs/direct_write.c
@@ -115,8 +115,11 @@ static int netfs_unbuffered_write(struct netfs_io_request *wreq)

/* Check if (re-)preparation failed. */
if (unlikely(test_bit(NETFS_SREQ_FAILED, &subreq->flags))) {
- netfs_write_subrequest_terminated(subreq, subreq->error);
+ if (!stream->construct)
+ netfs_get_subrequest(subreq, netfs_sreq_trace_get_resubmit);
wreq->error = subreq->error;
+ netfs_write_subrequest_terminated(subreq, subreq->error);
+ ret = wreq->error;
break;
}


syzbot

unread,
May 31, 2026, 1:02:03 AM (9 days ago) May 31
to ead...@qq.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine



Tested on:

commit: 174914ea Merge tag 'v7.1-rc6-smb3-client-fixes' of git..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12ee5ef2580000
kernel config: https://syzkaller.appspot.com/x/.config?x=8118209836970b54
dashboard link: https://syzkaller.appspot.com/bug?extid=3c74b1f0c372e98efc32
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=1188c27a580000

hongao

unread,
May 31, 2026, 12:53:12 PM (8 days ago) May 31
to syzbot+3c74b1...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
From 57d3537f407aaf4229abc9b78513c6222cbfb799 Mon Sep 17 00:00:00 2001
From: hongao <hon...@uniontech.com>
Date: Sat, 30 May 2026 09:08:24 +0800
Subject: [PATCH] netfs: Fix UAF in netfs_unbuffered_write() on failed
preparation

If write subrequest preparation fails, netfs_unbuffered_write() calls
netfs_write_subrequest_terminated() and then reads subreq->error to set
wreq->error.

However, netfs_write_subrequest_terminated() consumes a reference to the
subrequest through netfs_put_subrequest(), so the subrequest may be freed
before netfs_unbuffered_write() reads subreq->error again. This can
trigger a slab-use-after-free.

Save the error locally before terminating the subrequest, and use the
saved value afterwards.

Fixes: a0b4c7a49137 ("netfs: Fix unbuffered/DIO writes to dispatch subrequests in strict sequence")
Reported-by: syzbot+3c74b1...@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=3c74b1f0c372e98efc32

Signed-off-by: hongao <hon...@uniontech.com>
---
fs/netfs/direct_write.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/netfs/direct_write.c b/fs/netfs/direct_write.c
index 25f8ceb15fad..2d5361702076 100644
--- a/fs/netfs/direct_write.c
+++ b/fs/netfs/direct_write.c
@@ -115,8 +115,9 @@ static int netfs_unbuffered_write(struct netfs_io_request *wreq)

/* Check if (re-)preparation failed. */
if (unlikely(test_bit(NETFS_SREQ_FAILED, &subreq->flags))) {
- netfs_write_subrequest_terminated(subreq, subreq->error);

hongao

unread,
May 31, 2026, 12:53:12 PM (8 days ago) May 31
to syzbot+3c74b1...@syzkaller.appspotmail.com, syzkall...@googlegroups.com, hongao
Reply all
Reply to author
Forward
0 new messages