Re: [syzbot] [syzbot] [fs?] general protection fault in iter_file_splice_write

From: syzbot
Date: Thu May 23 2024 - 05:25:58 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx.

***

Subject: [syzbot] [fs?] general protection fault in iter_file_splice_write
Author: lizhi.xu@xxxxxxxxxxxxx

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 33e02dc69afb

diff --git a/fs/splice.c b/fs/splice.c
index 60aed8de21f8..35a99fdabe9c 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -751,8 +751,18 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,

/* dismiss the fully eaten buffers, adjust the partial one */
tail = pipe->tail;
- while (ret) {
+ while (ret > 0) {
struct pipe_buffer *buf = &pipe->bufs[tail & mask];
+ printk("ret: %d, nbufs: %d, buf len: %u, m: %u, t: %u,ring size: %u, bufs len: %d, %s\n", ret, nbufs, buf->len, mask, tail, pipe->ring_size, ARRAY_SIZE(pipe->bufs), __func__);
+ if (ARRAY_SIZE(pipe->bufs) <= mask) {
+ ret = -EPIPE;
+ printk("oooh, %s\n", __func__);
+ break;
+ }
+ if (!buf->len) {
+ tail++;
+ continue;
+ }
if (ret >= buf->len) {
ret -= buf->len;
buf->len = 0;