* [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one
@ 2025-02-14 5:55 syzbot
2025-02-14 12:46 ` Edward Adam Davis
` (8 more replies)
0 siblings, 9 replies; 18+ messages in thread
From: syzbot @ 2025-02-14 5:55 UTC (permalink / raw)
To: dhowells, jlayton, linux-fsdevel, linux-kernel, netfs,
syzkaller-bugs
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=147e83f8580000
kernel config: https://syzkaller.appspot.com/x/.config?x=a7ddf49cf33ba213
dashboard link: https://syzkaller.appspot.com/bug?extid=e1dc29a4daf3f8051130
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=118998e4580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10fcbb18580000
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+e1dc29a4daf3f8051130@syzkaller.appspotmail.com
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 ffff8880317b3b08 by task syz-executor210/6000
CPU: 3 UID: 0 PID: 6000 Comm: syz-executor210 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
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:0x7f9104587229
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 81 1d 00 00 90 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f9104537168 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1
RAX: ffffffffffffffda RBX: 00007f910460b408 RCX: 00007f9104587229
RDX: 00004000000002c0 RSI: 0000000000000001 RDI: 00007f9104516000
RBP: 00007f910460b400 R08: 00007f91045376c0 R09: 0000000000000000
R10: 00007f91045376c0 R11: 0000000000000246 R12: 00007f910460b40c
R13: 000000000000000b R14: 00007fff6ba87360 R15: 00007fff6ba87448
</TASK>
Allocated by task 6000:
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 6000:
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:375 [inline]
netfs_read_collection+0x30ae/0x3cb0 fs/netfs/read_collect.c:438
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
The buggy address belongs to the object at ffff8880317b3a40
which belongs to the cache aio_kiocb of size 216
The buggy address is located 200 bytes inside of
freed 216-byte region [ffff8880317b3a40, ffff8880317b3b18)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x317b2
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 ffff888100e8e280 dead000000000122 0000000000000000
raw: 0000000000000000 0000000080190019 00000000f5000000 0000000000000000
head: 00fff00000000040 ffff888100e8e280 dead000000000122 0000000000000000
head: 0000000000000000 0000000080190019 00000000f5000000 0000000000000000
head: 00fff00000000001 ffffea0000c5ec81 ffffffffffffffff 0000000000000000
head: ffff888000000002 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 5956, tgid 5955 (syz-executor210), ts 65172573555, free_ts 65103511107
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 0 tgid 0 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
__do_softirq kernel/softirq.c:595 [inline]
invoke_softirq kernel/softirq.c:435 [inline]
__irq_exit_rcu+0x109/0x170 kernel/softirq.c:662
irq_exit_rcu+0x9/0x30 kernel/softirq.c:678
instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1049 [inline]
sysvec_apic_timer_interrupt+0xa4/0xc0 arch/x86/kernel/apic/apic.c:1049
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:702
Memory state around the buggy address:
ffff8880317b3a00: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
ffff8880317b3a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880317b3b00: fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc
^
ffff8880317b3b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880317b3c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
---
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 syzkaller@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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-14 5:55 [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one syzbot
@ 2025-02-14 12:46 ` Edward Adam Davis
2025-02-14 12:57 ` [syzbot] " syzbot
2025-02-15 0:59 ` Edward Adam Davis
` (7 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Edward Adam Davis @ 2025-02-14 12:46 UTC (permalink / raw)
To: syzbot+e1dc29a4daf3f8051130; +Cc: linux-kernel, syzkaller-bugs
#syz test
diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c
index f65affa5a9e4..40c408705f1a 100644
--- a/fs/netfs/read_collect.c
+++ b/fs/netfs/read_collect.c
@@ -371,9 +371,13 @@ static void netfs_rreq_assess_dio(struct netfs_io_request *rreq)
if (rreq->iocb) {
rreq->iocb->ki_pos += rreq->transferred;
- if (rreq->iocb->ki_complete)
+ if (rreq->iocb->ki_complete) {
+ if (rreq->transferred < rreq->len)
+ refcount_add_not_zero(&rreq->iocb->ki_refcnt);
+
rreq->iocb->ki_complete(
rreq->iocb, rreq->error ? rreq->error : rreq->transferred);
+ }
}
if (rreq->netfs_ops->done)
rreq->netfs_ops->done(rreq);
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-14 12:46 ` Edward Adam Davis
@ 2025-02-14 12:57 ` syzbot
0 siblings, 0 replies; 18+ messages in thread
From: syzbot @ 2025-02-14 12:57 UTC (permalink / raw)
To: eadavis, linux-kernel, syzkaller-bugs
Hello,
syzbot tried to test the proposed patch but the build/boot failed:
fs/netfs/read_collect.c:376:66: error: 'struct kiocb' has no member named 'ki_refcnt'
fs/netfs/read_collect.c:376:33: error: too few arguments to function 'refcount_add_not_zero'
Tested on:
commit: 128c8f96 Merge tag 'drm-fixes-2025-02-14' of https://g..
git tree: upstream
kernel config: https://syzkaller.appspot.com/x/.config?x=a7ddf49cf33ba213
dashboard link: https://syzkaller.appspot.com/bug?extid=e1dc29a4daf3f8051130
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=16c14ce4580000
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-14 5:55 [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one syzbot
2025-02-14 12:46 ` Edward Adam Davis
@ 2025-02-15 0:59 ` Edward Adam Davis
2025-02-15 1:23 ` [syzbot] " syzbot
2025-02-15 2:00 ` Edward Adam Davis
` (6 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Edward Adam Davis @ 2025-02-15 0:59 UTC (permalink / raw)
To: syzbot+e1dc29a4daf3f8051130; +Cc: linux-kernel, syzkaller-bugs
#syz test
diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c
index f65affa5a9e4..7854d55120b8 100644
--- a/fs/netfs/read_collect.c
+++ b/fs/netfs/read_collect.c
@@ -371,9 +371,11 @@ static void netfs_rreq_assess_dio(struct netfs_io_request *rreq)
if (rreq->iocb) {
rreq->iocb->ki_pos += rreq->transferred;
- if (rreq->iocb->ki_complete)
+ if (rreq->iocb->ki_complete) {
rreq->iocb->ki_complete(
rreq->iocb, rreq->error ? rreq->error : rreq->transferred);
+ rreq->iocb->ki_complete = NULL;
+ }
}
if (rreq->netfs_ops->done)
rreq->netfs_ops->done(rreq);
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-15 0:59 ` Edward Adam Davis
@ 2025-02-15 1:23 ` syzbot
0 siblings, 0 replies; 18+ messages in thread
From: syzbot @ 2025-02-15 1:23 UTC (permalink / raw)
To: eadavis, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Write in netfs_read_collection
==================================================================
BUG: KASAN: slab-use-after-free in netfs_rreq_assess_dio fs/netfs/read_collect.c:377 [inline]
BUG: KASAN: slab-use-after-free in netfs_read_collection+0x3baa/0x3d10 fs/netfs/read_collect.c:440
Write of size 8 at addr ffff8880310c6650 by task kworker/u32:2/45
CPU: 0 UID: 0 PID: 45 Comm: kworker/u32:2 Not tainted 6.14.0-rc2-syzkaller-g78a632a2086c-dirty #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Workqueue: events_unbound netfs_read_collection_worker
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
netfs_rreq_assess_dio fs/netfs/read_collect.c:377 [inline]
netfs_read_collection+0x3baa/0x3d10 fs/netfs/read_collect.c:440
netfs_read_collection_worker+0x285/0x350 fs/netfs/read_collect.c:466
process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3236
process_scheduled_works kernel/workqueue.c:3317 [inline]
worker_thread+0x6c8/0xf00 kernel/workqueue.c:3398
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
</TASK>
Allocated by task 6706:
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 45:
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:375 [inline]
netfs_read_collection+0x30b3/0x3d10 fs/netfs/read_collect.c:440
netfs_read_collection_worker+0x285/0x350 fs/netfs/read_collect.c:466
process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3236
process_scheduled_works kernel/workqueue.c:3317 [inline]
worker_thread+0x6c8/0xf00 kernel/workqueue.c:3398
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
The buggy address belongs to the object at ffff8880310c6640
which belongs to the cache aio_kiocb of size 216
The buggy address is located 16 bytes inside of
freed 216-byte region [ffff8880310c6640, ffff8880310c6718)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff8880310c7e00 pfn:0x310c6
head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
anon flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88801bb3bcc0 0000000000000000 0000000000000001
raw: ffff8880310c7e00 0000000080190015 00000000f5000000 0000000000000000
head: 00fff00000000040 ffff88801bb3bcc0 0000000000000000 0000000000000001
head: ffff8880310c7e00 0000000080190015 00000000f5000000 0000000000000000
head: 00fff00000000001 ffffea0000c43181 ffffffffffffffff 0000000000000000
head: ffff888000000002 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 6549, tgid 6548 (syz.0.17), ts 88470255044, free_ts 87864364394
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 6535 tgid 6535 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
mm_free_pgd kernel/fork.c:815 [inline]
__mmdrop+0xd5/0x460 kernel/fork.c:931
mmdrop include/linux/sched/mm.h:55 [inline]
__mmput+0x36c/0x410 kernel/fork.c:1367
mmput+0x62/0x70 kernel/fork.c:1378
exec_mmap fs/exec.c:1011 [inline]
begin_new_exec+0x152b/0x3800 fs/exec.c:1267
load_elf_binary+0x886/0x4fc0 fs/binfmt_elf.c:1002
search_binary_handler fs/exec.c:1775 [inline]
exec_binprm fs/exec.c:1807 [inline]
bprm_execve fs/exec.c:1859 [inline]
bprm_execve+0x8dd/0x16d0 fs/exec.c:1835
do_execveat_common.isra.0+0x4a2/0x610 fs/exec.c:1966
do_execve fs/exec.c:2040 [inline]
__do_sys_execve fs/exec.c:2116 [inline]
__se_sys_execve fs/exec.c:2111 [inline]
__x64_sys_execve+0x8c/0xb0 fs/exec.c:2111
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
Memory state around the buggy address:
ffff8880310c6500: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880310c6580: fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc fc
>ffff8880310c6600: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
^
ffff8880310c6680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880310c6700: fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
Tested on:
commit: 78a632a2 Merge tag 'pci-v6.14-fixes-3' of git://git.ke..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=159267df980000
kernel config: https://syzkaller.appspot.com/x/.config?x=c09dc55ba7f798e3
dashboard link: https://syzkaller.appspot.com/bug?extid=e1dc29a4daf3f8051130
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=10178bf8580000
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-14 5:55 [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one syzbot
2025-02-14 12:46 ` Edward Adam Davis
2025-02-15 0:59 ` Edward Adam Davis
@ 2025-02-15 2:00 ` Edward Adam Davis
2025-02-15 2:19 ` [syzbot] " syzbot
2025-02-15 2:36 ` Edward Adam Davis
` (5 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Edward Adam Davis @ 2025-02-15 2:00 UTC (permalink / raw)
To: syzbot+e1dc29a4daf3f8051130; +Cc: linux-kernel, syzkaller-bugs
#syz test
diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c
index f65affa5a9e4..93eb315fffea 100644
--- a/fs/netfs/read_collect.c
+++ b/fs/netfs/read_collect.c
@@ -371,9 +371,11 @@ static void netfs_rreq_assess_dio(struct netfs_io_request *rreq)
if (rreq->iocb) {
rreq->iocb->ki_pos += rreq->transferred;
- if (rreq->iocb->ki_complete)
+ if (rreq->iocb->ki_complete) {
rreq->iocb->ki_complete(
rreq->iocb, rreq->error ? rreq->error : rreq->transferred);
+ rreq->iocb = NULL;
+ }
}
if (rreq->netfs_ops->done)
rreq->netfs_ops->done(rreq);
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-15 2:00 ` Edward Adam Davis
@ 2025-02-15 2:19 ` syzbot
0 siblings, 0 replies; 18+ messages in thread
From: syzbot @ 2025-02-15 2:19 UTC (permalink / raw)
To: eadavis, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in netfs_read_collection
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
CPU: 1 UID: 0 PID: 103 Comm: kworker/u32:5 Not tainted 6.14.0-rc2-syzkaller-g78a632a2086c-dirty #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Workqueue: events_unbound netfs_read_collection_worker
RIP: 0010:netfs_rreq_assess_dio fs/netfs/read_collect.c:374 [inline]
RIP: 0010:netfs_read_collection+0x3045/0x3ce0 fs/netfs/read_collect.c:440
Code: 0f 85 16 0b 00 00 4d 03 a6 88 02 00 00 48 b8 00 00 00 00 00 fc ff df 4c 89 65 08 49 8b 6e 58 48 8d 7d 10 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 de 0a 00 00 4c 8b 65 10 4d 85 e4 74 7d e8 e3 55
RSP: 0018:ffffc9000171fb10 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: ffff88804a5f6dd8 RCX: ffffffff82668821
RDX: 0000000000000002 RSI: ffffffff826680c3 RDI: 0000000000000010
RBP: 0000000000000000 R08: 0000000000000004 R09: 0000000000000001
R10: 0000000000000001 R11: 0000000000000001 R12: 00000000ff010000
R13: ffff88804a5f7008 R14: ffff88804a5f6d80 R15: ffff88804a5f6f98
FS: 0000000000000000(0000) GS:ffff88806a700000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b3185ffff CR3: 000000002a4a6000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
netfs_read_collection_worker+0x285/0x350 fs/netfs/read_collect.c:466
process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3236
process_scheduled_works kernel/workqueue.c:3317 [inline]
worker_thread+0x6c8/0xf00 kernel/workqueue.c:3398
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
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:netfs_rreq_assess_dio fs/netfs/read_collect.c:374 [inline]
RIP: 0010:netfs_read_collection+0x3045/0x3ce0 fs/netfs/read_collect.c:440
Code: 0f 85 16 0b 00 00 4d 03 a6 88 02 00 00 48 b8 00 00 00 00 00 fc ff df 4c 89 65 08 49 8b 6e 58 48 8d 7d 10 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 de 0a 00 00 4c 8b 65 10 4d 85 e4 74 7d e8 e3 55
RSP: 0018:ffffc9000171fb10 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: ffff88804a5f6dd8 RCX: ffffffff82668821
RDX: 0000000000000002 RSI: ffffffff826680c3 RDI: 0000000000000010
RBP: 0000000000000000 R08: 0000000000000004 R09: 0000000000000001
R10: 0000000000000001 R11: 0000000000000001 R12: 00000000ff010000
R13: ffff88804a5f7008 R14: ffff88804a5f6d80 R15: ffff88804a5f6f98
FS: 0000000000000000(0000) GS:ffff88806a700000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b3185ffff CR3: 000000002a4a6000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 0f 85 16 0b 00 00 jne 0xb1c
6: 4d 03 a6 88 02 00 00 add 0x288(%r14),%r12
d: 48 b8 00 00 00 00 00 movabs $0xdffffc0000000000,%rax
14: fc ff df
17: 4c 89 65 08 mov %r12,0x8(%rbp)
1b: 49 8b 6e 58 mov 0x58(%r14),%rbp
1f: 48 8d 7d 10 lea 0x10(%rbp),%rdi
23: 48 89 fa mov %rdi,%rdx
26: 48 c1 ea 03 shr $0x3,%rdx
* 2a: 80 3c 02 00 cmpb $0x0,(%rdx,%rax,1) <-- trapping instruction
2e: 0f 85 de 0a 00 00 jne 0xb12
34: 4c 8b 65 10 mov 0x10(%rbp),%r12
38: 4d 85 e4 test %r12,%r12
3b: 74 7d je 0xba
3d: e8 .byte 0xe8
3e: e3 55 jrcxz 0x95
Tested on:
commit: 78a632a2 Merge tag 'pci-v6.14-fixes-3' of git://git.ke..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=109b19a4580000
kernel config: https://syzkaller.appspot.com/x/.config?x=c09dc55ba7f798e3
dashboard link: https://syzkaller.appspot.com/bug?extid=e1dc29a4daf3f8051130
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=17df8bf8580000
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-14 5:55 [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one syzbot
` (2 preceding siblings ...)
2025-02-15 2:00 ` Edward Adam Davis
@ 2025-02-15 2:36 ` Edward Adam Davis
2025-02-15 2:57 ` [syzbot] " syzbot
2025-02-15 3:50 ` Edward Adam Davis
` (4 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Edward Adam Davis @ 2025-02-15 2:36 UTC (permalink / raw)
To: syzbot+e1dc29a4daf3f8051130; +Cc: linux-kernel, syzkaller-bugs
#syz test
diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c
index f65affa5a9e4..73fea10d9a78 100644
--- a/fs/netfs/read_collect.c
+++ b/fs/netfs/read_collect.c
@@ -369,12 +369,17 @@ static void netfs_rreq_assess_dio(struct netfs_io_request *rreq)
}
}
+ spin_lock(&rreq->lock);
if (rreq->iocb) {
rreq->iocb->ki_pos += rreq->transferred;
- if (rreq->iocb->ki_complete)
+ if (rreq->iocb->ki_complete) {
rreq->iocb->ki_complete(
rreq->iocb, rreq->error ? rreq->error : rreq->transferred);
+ rreq->iocb = NULL;
+ }
}
+ spin_unlock(&rreq->lock);
+
if (rreq->netfs_ops->done)
rreq->netfs_ops->done(rreq);
if (rreq->origin == NETFS_DIO_READ)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-15 2:36 ` Edward Adam Davis
@ 2025-02-15 2:57 ` syzbot
0 siblings, 0 replies; 18+ messages in thread
From: syzbot @ 2025-02-15 2:57 UTC (permalink / raw)
To: eadavis, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING: refcount bug in netfs_put_subrequest
------------[ cut here ]------------
refcount_t: underflow; use-after-free.
WARNING: CPU: 1 PID: 81 at lib/refcount.c:28 refcount_warn_saturate+0x14a/0x210 lib/refcount.c:28
Modules linked in:
CPU: 1 UID: 0 PID: 81 Comm: kworker/u32:4 Not tainted 6.14.0-rc2-syzkaller-g78a632a2086c-dirty #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Workqueue: events_unbound netfs_read_collection_worker
RIP: 0010:refcount_warn_saturate+0x14a/0x210 lib/refcount.c:28
Code: ff 89 de e8 c8 5a f5 fc 84 db 0f 85 66 ff ff ff e8 1b 60 f5 fc c6 05 d7 5c 86 0b 01 90 48 c7 c7 c0 00 d3 8b e8 77 99 b5 fc 90 <0f> 0b 90 90 e9 43 ff ff ff e8 f8 5f f5 fc 0f b6 1d b2 5c 86 0b 31
RSP: 0018:ffffc9000162fab8 EFLAGS: 00010282
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff817a1229
RDX: ffff888020af2440 RSI: ffffffff817a1236 RDI: 0000000000000001
RBP: ffff8880305354a0 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000002 R12: 0000000000000005
R13: 00000000000006ed R14: 0000000000000001 R15: ffff8880305354a0
FS: 0000000000000000(0000) GS:ffff88806a700000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fb7675a2f98 CR3: 000000000df80000 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/0x3d00 fs/netfs/read_collect.c:422
netfs_read_collection_worker+0x285/0x350 fs/netfs/read_collect.c:469
process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3236
process_scheduled_works kernel/workqueue.c:3317 [inline]
worker_thread+0x6c8/0xf00 kernel/workqueue.c:3398
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
</TASK>
Tested on:
commit: 78a632a2 Merge tag 'pci-v6.14-fixes-3' of git://git.ke..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=123719a4580000
kernel config: https://syzkaller.appspot.com/x/.config?x=c09dc55ba7f798e3
dashboard link: https://syzkaller.appspot.com/bug?extid=e1dc29a4daf3f8051130
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=16a667df980000
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-14 5:55 [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one syzbot
` (3 preceding siblings ...)
2025-02-15 2:36 ` Edward Adam Davis
@ 2025-02-15 3:50 ` Edward Adam Davis
2025-02-15 3:51 ` [syzbot] " syzbot
2025-02-15 4:10 ` Edward Adam Davis
` (3 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Edward Adam Davis @ 2025-02-15 3:50 UTC (permalink / raw)
To: syzbot+e1dc29a4daf3f8051130; +Cc: linux-kernel, syzkaller-bugs
#syz test
diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c
index f65affa5a9e4..73fea10d9a78 100644
--- a/fs/netfs/read_collect.c
+++ b/fs/netfs/read_collect.c
@@ -369,12 +369,17 @@ static void netfs_rreq_assess_dio(struct netfs_io_request *rreq)
}
}
+ spin_lock(&rreq->lock);
if (rreq->iocb) {
rreq->iocb->ki_pos += rreq->transferred;
- if (rreq->iocb->ki_complete)
+ if (rreq->iocb->ki_complete) {
rreq->iocb->ki_complete(
rreq->iocb, rreq->error ? rreq->error : rreq->transferred);
+ rreq->iocb = NULL;
+ }
}
+ spin_unlock(&rreq->lock);
+
if (rreq->netfs_ops->done)
rreq->netfs_ops->done(rreq);
if (rreq->origin == NETFS_DIO_READ)
@@ -301,6 +301,8 @@ static void netfs_collect_read_results(struct netfs_io_request *rreq)
notes & ABANDON_SREQ ?
netfs_sreq_trace_put_abandon :
netfs_sreq_trace_put_done);
+ if (front == remove)
+ break;
}
trace_netfs_collect_stream(rreq, stream);
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-15 3:50 ` Edward Adam Davis
@ 2025-02-15 3:51 ` syzbot
0 siblings, 0 replies; 18+ messages in thread
From: syzbot @ 2025-02-15 3:51 UTC (permalink / raw)
To: eadavis, linux-kernel, syzkaller-bugs
Hello,
syzbot tried to test the proposed patch but the build/boot failed:
failed to apply patch:
checking file fs/netfs/read_collect.c
misordered hunks! output would be garbled
Hunk #2 FAILED at 306.
1 out of 2 hunks FAILED
Tested on:
commit: 78a632a2 Merge tag 'pci-v6.14-fixes-3' of git://git.ke..
git tree: upstream
kernel config: https://syzkaller.appspot.com/x/.config?x=a7ddf49cf33ba213
dashboard link: https://syzkaller.appspot.com/bug?extid=e1dc29a4daf3f8051130
compiler:
patch: https://syzkaller.appspot.com/x/patch.diff?x=132099a4580000
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-14 5:55 [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one syzbot
` (4 preceding siblings ...)
2025-02-15 3:50 ` Edward Adam Davis
@ 2025-02-15 4:10 ` Edward Adam Davis
2025-02-15 4:32 ` [syzbot] " syzbot
2025-02-15 5:15 ` Edward Adam Davis
` (2 subsequent siblings)
8 siblings, 1 reply; 18+ messages in thread
From: Edward Adam Davis @ 2025-02-15 4:10 UTC (permalink / raw)
To: syzbot+e1dc29a4daf3f8051130; +Cc: linux-kernel, syzkaller-bugs
#syz test
diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c
index f65affa5a9e4..72b08c1709fa 100644
--- a/fs/netfs/read_collect.c
+++ b/fs/netfs/read_collect.c
@@ -301,6 +301,8 @@ static void netfs_collect_read_results(struct netfs_io_request *rreq)
notes & ABANDON_SREQ ?
netfs_sreq_trace_put_abandon :
netfs_sreq_trace_put_done);
+ if (front == remove)
+ break;
}
trace_netfs_collect_stream(rreq, stream);
@@ -369,12 +371,17 @@ static void netfs_rreq_assess_dio(struct netfs_io_request *rreq)
}
}
+ spin_lock(&rreq->lock);
if (rreq->iocb) {
rreq->iocb->ki_pos += rreq->transferred;
- if (rreq->iocb->ki_complete)
+ if (rreq->iocb->ki_complete) {
rreq->iocb->ki_complete(
rreq->iocb, rreq->error ? rreq->error : rreq->transferred);
+ rreq->iocb = NULL;
+ }
}
+ spin_unlock(&rreq->lock);
+
if (rreq->netfs_ops->done)
rreq->netfs_ops->done(rreq);
if (rreq->origin == NETFS_DIO_READ)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-15 4:10 ` Edward Adam Davis
@ 2025-02-15 4:32 ` syzbot
0 siblings, 0 replies; 18+ messages in thread
From: syzbot @ 2025-02-15 4:32 UTC (permalink / raw)
To: eadavis, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING: refcount bug in netfs_put_subrequest
------------[ cut here ]------------
refcount_t: underflow; use-after-free.
WARNING: CPU: 1 PID: 85 at lib/refcount.c:28 refcount_warn_saturate+0x14a/0x210 lib/refcount.c:28
Modules linked in:
CPU: 1 UID: 0 PID: 85 Comm: kworker/u32:4 Not tainted 6.14.0-rc2-syzkaller-g7ff71e6d9239-dirty #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Workqueue: events_unbound netfs_read_collection_worker
RIP: 0010:refcount_warn_saturate+0x14a/0x210 lib/refcount.c:28
Code: ff 89 de e8 08 5b f5 fc 84 db 0f 85 66 ff ff ff e8 5b 60 f5 fc c6 05 17 5d 86 0b 01 90 48 c7 c7 c0 00 d3 8b e8 b7 99 b5 fc 90 <0f> 0b 90 90 e9 43 ff ff ff e8 38 60 f5 fc 0f b6 1d f2 5c 86 0b 31
RSP: 0018:ffffc90000fdfac0 EFLAGS: 00010286
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff817a1229
RDX: ffff888021798000 RSI: ffffffff817a1236 RDI: 0000000000000001
RBP: ffff888030d38e60 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000002 R12: 0000000000000005
R13: 0000000000000135 R14: 0000000000000001 R15: ffff888030d38e60
FS: 0000000000000000(0000) GS:ffff88806a700000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000c0022d90a0 CR3: 0000000023ac0000 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+0x1f09/0x3cc0 fs/netfs/read_collect.c:424
netfs_read_collection_worker+0x285/0x350 fs/netfs/read_collect.c:471
process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3236
process_scheduled_works kernel/workqueue.c:3317 [inline]
worker_thread+0x6c8/0xf00 kernel/workqueue.c:3398
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
</TASK>
Tested on:
commit: 7ff71e6d Merge tag 'alpha-fixes-v6.14-rc2' of git://gi..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=142967df980000
kernel config: https://syzkaller.appspot.com/x/.config?x=c09dc55ba7f798e3
dashboard link: https://syzkaller.appspot.com/bug?extid=e1dc29a4daf3f8051130
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=143167df980000
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-14 5:55 [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one syzbot
` (5 preceding siblings ...)
2025-02-15 4:10 ` Edward Adam Davis
@ 2025-02-15 5:15 ` Edward Adam Davis
2025-02-15 5:38 ` [syzbot] " syzbot
2025-02-15 7:43 ` Hillf Danton
2025-02-15 9:42 ` [PATCH] netfs: Prevent race conditions between aio read and read collection worker Edward Adam Davis
8 siblings, 1 reply; 18+ messages in thread
From: Edward Adam Davis @ 2025-02-15 5:15 UTC (permalink / raw)
To: syzbot+e1dc29a4daf3f8051130; +Cc: linux-kernel, syzkaller-bugs
#syz test
diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c
index f65affa5a9e4..6f3c0404f4b8 100644
--- a/fs/netfs/read_collect.c
+++ b/fs/netfs/read_collect.c
@@ -207,6 +207,7 @@ static void netfs_collect_read_results(struct netfs_io_request *rreq)
* in progress. The issuer thread may be adding stuff to the tail
* whilst we're doing this.
*/
+ spin_lock(&rreq->lock);
front = READ_ONCE(stream->front);
while (front) {
size_t transferred;
@@ -288,7 +289,6 @@ static void netfs_collect_read_results(struct netfs_io_request *rreq)
/* Remove if completely consumed. */
stream->source = front->source;
- spin_lock(&rreq->lock);
remove = front;
trace_netfs_sreq(front, netfs_sreq_trace_discard);
@@ -296,12 +296,12 @@ static void netfs_collect_read_results(struct netfs_io_request *rreq)
front = list_first_entry_or_null(&stream->subrequests,
struct netfs_io_subrequest, rreq_link);
stream->front = front;
- spin_unlock(&rreq->lock);
netfs_put_subrequest(remove, false,
notes & ABANDON_SREQ ?
netfs_sreq_trace_put_abandon :
netfs_sreq_trace_put_done);
}
+ spin_unlock(&rreq->lock);
trace_netfs_collect_stream(rreq, stream);
trace_netfs_collect_state(rreq, rreq->collected_to, notes);
@@ -369,12 +369,17 @@ static void netfs_rreq_assess_dio(struct netfs_io_request *rreq)
}
}
+ spin_lock(&rreq->lock);
if (rreq->iocb) {
rreq->iocb->ki_pos += rreq->transferred;
- if (rreq->iocb->ki_complete)
+ if (rreq->iocb->ki_complete) {
rreq->iocb->ki_complete(
rreq->iocb, rreq->error ? rreq->error : rreq->transferred);
+ rreq->iocb = NULL;
+ }
}
+ spin_unlock(&rreq->lock);
+
if (rreq->netfs_ops->done)
rreq->netfs_ops->done(rreq);
if (rreq->origin == NETFS_DIO_READ)
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-15 5:15 ` Edward Adam Davis
@ 2025-02-15 5:38 ` syzbot
0 siblings, 0 replies; 18+ messages in thread
From: syzbot @ 2025-02-15 5:38 UTC (permalink / raw)
To: eadavis, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-by: syzbot+e1dc29a4daf3f8051130@syzkaller.appspotmail.com
Tested-by: syzbot+e1dc29a4daf3f8051130@syzkaller.appspotmail.com
Tested on:
commit: 7ff71e6d Merge tag 'alpha-fixes-v6.14-rc2' of git://gi..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=13abd9b0580000
kernel config: https://syzkaller.appspot.com/x/.config?x=c09dc55ba7f798e3
dashboard link: https://syzkaller.appspot.com/bug?extid=e1dc29a4daf3f8051130
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=11924bf8580000
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-14 5:55 [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one syzbot
` (6 preceding siblings ...)
2025-02-15 5:15 ` Edward Adam Davis
@ 2025-02-15 7:43 ` Hillf Danton
2025-02-15 8:10 ` syzbot
2025-02-15 9:42 ` [PATCH] netfs: Prevent race conditions between aio read and read collection worker Edward Adam Davis
8 siblings, 1 reply; 18+ messages in thread
From: Hillf Danton @ 2025-02-15 7:43 UTC (permalink / raw)
To: syzbot; +Cc: linux-kernel, syzkaller-bugs
On Thu, 13 Feb 2025 21:55:19 -0800
> syzbot found the following issue on:
>
> HEAD commit: 69b54314c975 Merge tag 'kbuild-fixes-v6.14' of git://git.k..
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10fcbb18580000
#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)
--
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one
2025-02-15 7:43 ` Hillf Danton
@ 2025-02-15 8:10 ` syzbot
0 siblings, 0 replies; 18+ messages in thread
From: syzbot @ 2025-02-15 8:10 UTC (permalink / raw)
To: hdanton, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-by: syzbot+e1dc29a4daf3f8051130@syzkaller.appspotmail.com
Tested-by: syzbot+e1dc29a4daf3f8051130@syzkaller.appspotmail.com
Tested on:
commit: 7ff71e6d Merge tag 'alpha-fixes-v6.14-rc2' of git://gi..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=107d6098580000
kernel config: https://syzkaller.appspot.com/x/.config?x=c09dc55ba7f798e3
dashboard link: https://syzkaller.appspot.com/bug?extid=e1dc29a4daf3f8051130
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=126e99a4580000
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH] netfs: Prevent race conditions between aio read and read collection worker
2025-02-14 5:55 [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one syzbot
` (7 preceding siblings ...)
2025-02-15 7:43 ` Hillf Danton
@ 2025-02-15 9:42 ` Edward Adam Davis
8 siblings, 0 replies; 18+ messages in thread
From: Edward Adam Davis @ 2025-02-15 9:42 UTC (permalink / raw)
To: syzbot+e1dc29a4daf3f8051130
Cc: dhowells, jlayton, linux-fsdevel, linux-kernel, netfs,
syzkaller-bugs
syzbot reported a slab-use-after-free Write in io_submit_one. [1]
netfs_read_collection() can be reached by two paths: netfs read collection
worker and aio read.
In aio_get_req(), ki_refcnt is set to 2.
CPU1 CPU2
============== ==================
io_submit_one
->io_get_req
->__io_submit_one
-->aio_read
-->v9fs_file_read_iter
-->netfs_unbuffered_read_iter
-->netfs_unbuffered_read process_one_work
-->netfs_dispatch_unbuffered_reads netfs_read_collection_worker
-->netfs_wait_for_pause netfs_read_collection
-->netfs_read_collection netfs_rreq_assess_dio
-->netfs_rreq_assess_dio aio_complete_rw
-->aio_complete_rw iocb_put
-->iocb_put
->iocb_put
The netfs read collection worker calls ki_complete() once, plus aio_read calls
ki_complete() once, causing iocb to be released before iocb_put is executed
in io_submit_one(), which triggers [1].
The aio read and netfs read collection worker are synchronized by locking
"rreq->lock" in netfs_rreq_assess_dio(), and iocb is set to NULL to prevent
ki_complete from being executed repeatedly by aio_read and worker.
[2] This is also caused by the race condition between aio_read and netfs
read collection worker mentioned above. We deal with it here by expanding
the lock range of "rreq->lock" for both to ensure that stream->front will
not be modified by the other party before the remove is executed.
[1]
BUG: KASAN: slab-use-after-free in io_submit_one+0x4e5/0x1da0 fs/aio.c:2055
Write of size 4 at addr ffff8880317b3b08 by task syz-executor210/6000
CPU: 3 UID: 0 PID: 6000 Comm: syz-executor210 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
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:0x7f9104587229
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 81 1d 00 00 90 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f9104537168 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1
RAX: ffffffffffffffda RBX: 00007f910460b408 RCX: 00007f9104587229
RDX: 00004000000002c0 RSI: 0000000000000001 RDI: 00007f9104516000
RBP: 00007f910460b400 R08: 00007f91045376c0 R09: 0000000000000000
R10: 00007f91045376c0 R11: 0000000000000246 R12: 00007f910460b40c
R13: 000000000000000b R14: 00007fff6ba87360 R15: 00007fff6ba87448
</TASK>
Allocated by task 6000:
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 6000:
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:375 [inline]
netfs_read_collection+0x30ae/0x3cb0 fs/netfs/read_collect.c:438
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
[2]
WARNING: CPU: 1 PID: 81 at lib/refcount.c:28 refcount_warn_saturate+0x14a/0x210 lib/refcount.c:28
Modules linked in:
CPU: 1 UID: 0 PID: 81 Comm: kworker/u32:4 Not tainted 6.14.0-rc2-syzkaller-g78a632a2086c-dirty #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Workqueue: events_unbound netfs_read_collection_worker
RIP: 0010:refcount_warn_saturate+0x14a/0x210 lib/refcount.c:28
Code: ff 89 de e8 c8 5a f5 fc 84 db 0f 85 66 ff ff ff e8 1b 60 f5 fc c6 05 d7 5c 86 0b 01 90 48 c7 c7 c0 00 d3 8b e8 77 99 b5 fc 90 <0f> 0b 90 90 e9 43 ff ff ff e8 f8 5f f5 fc 0f b6 1d b2 5c 86 0b 31
RSP: 0018:ffffc9000162fab8 EFLAGS: 00010282
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff817a1229
RDX: ffff888020af2440 RSI: ffffffff817a1236 RDI: 0000000000000001
RBP: ffff8880305354a0 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000002 R12: 0000000000000005
R13: 00000000000006ed R14: 0000000000000001 R15: ffff8880305354a0
FS: 0000000000000000(0000) GS:ffff88806a700000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fb7675a2f98 CR3: 000000000df80000 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/0x3d00 fs/netfs/read_collect.c:422
netfs_read_collection_worker+0x285/0x350 fs/netfs/read_collect.c:469
process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3236
process_scheduled_works kernel/workqueue.c:3317 [inline]
worker_thread+0x6c8/0xf00 kernel/workqueue.c:3398
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
</TASK>
Fixes: ee4cdf7ba857 ("netfs: Speed up buffered reading")
Reported-by: syzbot+e1dc29a4daf3f8051130@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e1dc29a4daf3f8051130
Tested-by: syzbot+e1dc29a4daf3f8051130@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
fs/netfs/read_collect.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c
index f65affa5a9e4..6f3c0404f4b8 100644
--- a/fs/netfs/read_collect.c
+++ b/fs/netfs/read_collect.c
@@ -207,6 +207,7 @@ static void netfs_collect_read_results(struct netfs_io_request *rreq)
* in progress. The issuer thread may be adding stuff to the tail
* whilst we're doing this.
*/
+ spin_lock(&rreq->lock);
front = READ_ONCE(stream->front);
while (front) {
size_t transferred;
@@ -288,7 +289,6 @@ static void netfs_collect_read_results(struct netfs_io_request *rreq)
/* Remove if completely consumed. */
stream->source = front->source;
- spin_lock(&rreq->lock);
remove = front;
trace_netfs_sreq(front, netfs_sreq_trace_discard);
@@ -296,12 +296,12 @@ static void netfs_collect_read_results(struct netfs_io_request *rreq)
front = list_first_entry_or_null(&stream->subrequests,
struct netfs_io_subrequest, rreq_link);
stream->front = front;
- spin_unlock(&rreq->lock);
netfs_put_subrequest(remove, false,
notes & ABANDON_SREQ ?
netfs_sreq_trace_put_abandon :
netfs_sreq_trace_put_done);
}
+ spin_unlock(&rreq->lock);
trace_netfs_collect_stream(rreq, stream);
trace_netfs_collect_state(rreq, rreq->collected_to, notes);
@@ -369,12 +369,17 @@ static void netfs_rreq_assess_dio(struct netfs_io_request *rreq)
}
}
+ spin_lock(&rreq->lock);
if (rreq->iocb) {
rreq->iocb->ki_pos += rreq->transferred;
- if (rreq->iocb->ki_complete)
+ if (rreq->iocb->ki_complete) {
rreq->iocb->ki_complete(
rreq->iocb, rreq->error ? rreq->error : rreq->transferred);
+ rreq->iocb = NULL;
+ }
}
+ spin_unlock(&rreq->lock);
+
if (rreq->netfs_ops->done)
rreq->netfs_ops->done(rreq);
if (rreq->origin == NETFS_DIO_READ)
--
2.43.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
end of thread, other threads:[~2025-02-15 9:49 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-14 5:55 [syzbot] [netfs?] KASAN: slab-use-after-free Write in io_submit_one syzbot
2025-02-14 12:46 ` Edward Adam Davis
2025-02-14 12:57 ` [syzbot] " syzbot
2025-02-15 0:59 ` Edward Adam Davis
2025-02-15 1:23 ` [syzbot] " syzbot
2025-02-15 2:00 ` Edward Adam Davis
2025-02-15 2:19 ` [syzbot] " syzbot
2025-02-15 2:36 ` Edward Adam Davis
2025-02-15 2:57 ` [syzbot] " syzbot
2025-02-15 3:50 ` Edward Adam Davis
2025-02-15 3:51 ` [syzbot] " syzbot
2025-02-15 4:10 ` Edward Adam Davis
2025-02-15 4:32 ` [syzbot] " syzbot
2025-02-15 5:15 ` Edward Adam Davis
2025-02-15 5:38 ` [syzbot] " syzbot
2025-02-15 7:43 ` Hillf Danton
2025-02-15 8:10 ` syzbot
2025-02-15 9:42 ` [PATCH] netfs: Prevent race conditions between aio read and read collection worker Edward Adam Davis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.