The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [syzbot] [netfs?] general protection fault in netfs_prepare_write
@ 2026-08-13 14:17 syzbot
  2026-08-14  0:36 ` Edward Adam Davis
  2026-08-14  2:16 ` [PATCH] netfs: break unbuffered write when netfs_alloc_subrequest() fails Edward Adam Davis
  0 siblings, 2 replies; 4+ messages in thread
From: syzbot @ 2026-08-13 14:17 UTC (permalink / raw)
  To: linux-kernel, netfs, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    3d6d817622b0 Merge tag 'scsi-fixes' of git://git.kernel.or..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=14832c79580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=c44651ea7dd2f307
dashboard link: https://syzkaller.appspot.com/bug?extid=6a13fc77eb6f0802be2d
compiler:       gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=12832c79580000

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

RBP: 0000000000000006 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f2bf1f9f288
R13: 0000000000000005 R14: 0000000000000000 R15: 00007f2bf1fa3252
 </TASK>
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000015: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x00000000000000a8-0x00000000000000af]
CPU: 3 UID: 0 PID: 6023 Comm: syz-executor218 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:netfs_prepare_write+0xbc/0x7b0 fs/netfs/write_issue.c:173
Code: e1 07 38 ca 7f 08 84 d2 0f 85 04 06 00 00 48 8d bb ad 00 00 00 0f b6 45 52 48 ba 00 00 00 00 00 fc ff df 48 89 f9 48 c1 e9 03 <0f> b6 14 11 48 89 f9 83 e1 07 38 ca 7f 08 84 d2 0f 85 c1 05 00 00
RSP: 0018:ffffc90003ea7b40 EFLAGS: 00010203
RAX: 0000000000000005 RBX: 0000000000000000 RCX: 0000000000000015
RDX: dffffc0000000000 RSI: ffffffff82cb9219 RDI: 00000000000000ad
RBP: ffff8880383da660 R08: 00000000ffffffff R09: fffffbfff1dbdcfe
R10: ffffffff8edee7f3 R11: 0000000000000000 R12: ffff8880383da580
R13: ffff8880383da738 R14: 000000000000001c R15: ffff8880383da6b2
FS:  000055558535c400(0000) GS:ffff8880d60ec000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000557b8da30300 CR3: 0000000028cd1000 CR4: 0000000000352ef0
Call Trace:
 <TASK>
 netfs_unbuffered_write+0x75c/0x2020 fs/netfs/direct_write.c:111
 netfs_unbuffered_write_iter_locked+0x7d6/0xa80 fs/netfs/direct_write.c:290
 netfs_unbuffered_write_iter+0x442/0x720 fs/netfs/direct_write.c:382
 v9fs_file_write_iter+0xbf/0x100 fs/9p/vfs_file.c:409
 new_sync_write fs/read_write.c:595 [inline]
 vfs_write+0x6ac/0x1050 fs/read_write.c:687
 ksys_write+0x12a/0x250 fs/read_write.c:739
 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:0x7f2bf1f5355e
Code: 08 0f 85 f5 e2 ff ff 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3> 90 41 57 41 56 4d 89 c6 41 55 4d 89 cd 41 54 55 53 48 83 ec 08
RSP: 002b:00007fffd127ea28 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 000055558535c400 RCX: 00007f2bf1f5355e
RDX: 0000000000000004 RSI: 00007f2bf1fa31f6 RDI: 0000000000000005
RBP: 0000000000000006 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f2bf1f9f288
R13: 0000000000000005 R14: 0000000000000000 R15: 00007f2bf1fa3252
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:netfs_prepare_write+0xbc/0x7b0 fs/netfs/write_issue.c:173
Code: e1 07 38 ca 7f 08 84 d2 0f 85 04 06 00 00 48 8d bb ad 00 00 00 0f b6 45 52 48 ba 00 00 00 00 00 fc ff df 48 89 f9 48 c1 e9 03 <0f> b6 14 11 48 89 f9 83 e1 07 38 ca 7f 08 84 d2 0f 85 c1 05 00 00
RSP: 0018:ffffc90003ea7b40 EFLAGS: 00010203
RAX: 0000000000000005 RBX: 0000000000000000 RCX: 0000000000000015
RDX: dffffc0000000000 RSI: ffffffff82cb9219 RDI: 00000000000000ad
RBP: ffff8880383da660 R08: 00000000ffffffff R09: fffffbfff1dbdcfe
R10: ffffffff8edee7f3 R11: 0000000000000000 R12: ffff8880383da580
R13: ffff8880383da738 R14: 000000000000001c R15: ffff8880383da6b2
FS:  000055558535c400(0000) GS:ffff8880d60ec000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000557b8da30300 CR3: 0000000028cd1000 CR4: 0000000000352ef0
----------------
Code disassembly (best guess):
   0:	e1 07                	loope  0x9
   2:	38 ca                	cmp    %cl,%dl
   4:	7f 08                	jg     0xe
   6:	84 d2                	test   %dl,%dl
   8:	0f 85 04 06 00 00    	jne    0x612
   e:	48 8d bb ad 00 00 00 	lea    0xad(%rbx),%rdi
  15:	0f b6 45 52          	movzbl 0x52(%rbp),%eax
  19:	48 ba 00 00 00 00 00 	movabs $0xdffffc0000000000,%rdx
  20:	fc ff df
  23:	48 89 f9             	mov    %rdi,%rcx
  26:	48 c1 e9 03          	shr    $0x3,%rcx
* 2a:	0f b6 14 11          	movzbl (%rcx,%rdx,1),%edx <-- trapping instruction
  2e:	48 89 f9             	mov    %rdi,%rcx
  31:	83 e1 07             	and    $0x7,%ecx
  34:	38 ca                	cmp    %cl,%dl
  36:	7f 08                	jg     0x40
  38:	84 d2                	test   %dl,%dl
  3a:	0f 85 c1 05 00 00    	jne    0x601


---
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] 4+ messages in thread

* Re: [syzbot] [netfs?] general protection fault in netfs_prepare_write
  2026-08-13 14:17 [syzbot] [netfs?] general protection fault in netfs_prepare_write syzbot
@ 2026-08-14  0:36 ` Edward Adam Davis
  2026-08-14  0:52   ` syzbot
  2026-08-14  2:16 ` [PATCH] netfs: break unbuffered write when netfs_alloc_subrequest() fails Edward Adam Davis
  1 sibling, 1 reply; 4+ messages in thread
From: Edward Adam Davis @ 2026-08-14  0:36 UTC (permalink / raw)
  To: syzbot+6a13fc77eb6f0802be2d; +Cc: linux-kernel, syzkaller-bugs

#syz test

diff --git a/fs/netfs/direct_write.c b/fs/netfs/direct_write.c
index c16fbad286a1..567b946b7a56 100644
--- a/fs/netfs/direct_write.c
+++ b/fs/netfs/direct_write.c
@@ -110,6 +110,10 @@ static int netfs_unbuffered_write(struct netfs_io_request *wreq)
 		if (!subreq) {
 			netfs_prepare_write(wreq, stream, wreq->start + wreq->transferred);
 			subreq = stream->construct;
+			if (!subreq) {
+				wreq->error = -ENOMEM;
+				break;
+			}
 			stream->construct = NULL;
 		}
 
diff --git a/fs/netfs/write_issue.c b/fs/netfs/write_issue.c
index 2d9cfcd43658..851f6f93ad45 100644
--- a/fs/netfs/write_issue.c
+++ b/fs/netfs/write_issue.c
@@ -170,6 +170,8 @@ void netfs_prepare_write(struct netfs_io_request *wreq,
 		rolling_buffer_make_space(&wreq->buffer, wreq->gfp);
 
 	subreq = netfs_alloc_subrequest(wreq);
+	if (!subreq)
+		return;
 	subreq->source		= stream->source;
 	subreq->start		= start;
 	subreq->stream_nr	= stream->stream_nr;


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [syzbot] [netfs?] general protection fault in netfs_prepare_write
  2026-08-14  0:36 ` Edward Adam Davis
@ 2026-08-14  0:52   ` syzbot
  0 siblings, 0 replies; 4+ messages in thread
From: syzbot @ 2026-08-14  0:52 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+6a13fc77eb6f0802be2d@syzkaller.appspotmail.com
Tested-by: syzbot+6a13fc77eb6f0802be2d@syzkaller.appspotmail.com

Tested on:

commit:         3aa1dcaa Revert "wifi: mt76: Disable napi when removin..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17f51a9e580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=c44651ea7dd2f307
dashboard link: https://syzkaller.appspot.com/bug?extid=6a13fc77eb6f0802be2d
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=15ad4ac6580000

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] netfs: break unbuffered write when netfs_alloc_subrequest() fails
  2026-08-13 14:17 [syzbot] [netfs?] general protection fault in netfs_prepare_write syzbot
  2026-08-14  0:36 ` Edward Adam Davis
@ 2026-08-14  2:16 ` Edward Adam Davis
  1 sibling, 0 replies; 4+ messages in thread
From: Edward Adam Davis @ 2026-08-14  2:16 UTC (permalink / raw)
  To: syzbot+6a13fc77eb6f0802be2d
  Cc: dhowells, pc, linux-fsdevel, linux-kernel, netfs, syzkaller-bugs

syzbot reported a null-ptr-deref below [1] following a fault injection in
netfs_alloc_subrequest(). [0]

When netfs_alloc_subrequest() fails, subreq is NULL.
Later, netfs_prepare_write() tries to initialize members of
subreq(e.g., source), the issue in [1] is triggered.

Let's handle the error of netfs_prepare_write() properly.

[0]
FAULT_INJECTION: forcing a failure.
name failslab, interval 1, probability 0, space 0, times 0
Call Trace:
 netfs_alloc_subrequest+0x116/0x3f0
 netfs_prepare_write+0x76/0x7b0
 netfs_unbuffered_write+0x75c/0x2020
 netfs_unbuffered_write_iter_locked+0x7d6/0xa80
 netfs_unbuffered_write_iter+0x442/0x720
 v9fs_file_write_iter+0xbf/0x100
 vfs_write+0x6ac/0x1050

[1]
KASAN: null-ptr-deref in range [0x00000000000000a8-0x00000000000000af]
RIP: 0010:netfs_prepare_write+0xbc/0x7b0 fs/netfs/write_issue.c:173
Call Trace:
 netfs_unbuffered_write+0x75c/0x2020 fs/netfs/direct_write.c:111
 netfs_unbuffered_write_iter_locked+0x7d6/0xa80 fs/netfs/direct_write.c:290
 netfs_unbuffered_write_iter+0x442/0x720 fs/netfs/direct_write.c:382
 v9fs_file_write_iter+0xbf/0x100 fs/9p/vfs_file.c:409
 new_sync_write fs/read_write.c:595 [inline]
 
Fixes: 288ace2f57c9 ("netfs: New writeback implementation")
Reported-by: syzbot+6a13fc77eb6f0802be2d@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=6a13fc77eb6f0802be2d
Tested-by: syzbot+6a13fc77eb6f0802be2d@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 fs/netfs/direct_write.c | 4 ++++
 fs/netfs/write_issue.c  | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/fs/netfs/direct_write.c b/fs/netfs/direct_write.c
index c16fbad286a1..567b946b7a56 100644
--- a/fs/netfs/direct_write.c
+++ b/fs/netfs/direct_write.c
@@ -110,6 +110,10 @@ static int netfs_unbuffered_write(struct netfs_io_request *wreq)
 		if (!subreq) {
 			netfs_prepare_write(wreq, stream, wreq->start + wreq->transferred);
 			subreq = stream->construct;
+			if (!subreq) {
+				wreq->error = -ENOMEM;
+				break;
+			}
 			stream->construct = NULL;
 		}
 
diff --git a/fs/netfs/write_issue.c b/fs/netfs/write_issue.c
index 2d9cfcd43658..851f6f93ad45 100644
--- a/fs/netfs/write_issue.c
+++ b/fs/netfs/write_issue.c
@@ -170,6 +170,8 @@ void netfs_prepare_write(struct netfs_io_request *wreq,
 		rolling_buffer_make_space(&wreq->buffer, wreq->gfp);
 
 	subreq = netfs_alloc_subrequest(wreq);
+	if (!subreq)
+		return;
 	subreq->source		= stream->source;
 	subreq->start		= start;
 	subreq->stream_nr	= stream->stream_nr;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-14  2:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 14:17 [syzbot] [netfs?] general protection fault in netfs_prepare_write syzbot
2026-08-14  0:36 ` Edward Adam Davis
2026-08-14  0:52   ` syzbot
2026-08-14  2:16 ` [PATCH] netfs: break unbuffered write when netfs_alloc_subrequest() fails Edward Adam Davis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox