Re: [syzbot] [fs?] general protection fault in iter_file_splice_write
From: Edward Adam Davis
Date: Wed May 22 2024 - 01:28:25 EST
please test null ptr in iter_file_splice_write
#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 218e24b1ac40..1a3c31f3e63a 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -392,6 +392,7 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos,
.offset = 0,
.len = chunk,
};
+ printk("buf: %p, ops: %p, %s\n", buf, buf->ops, __func__);
pipe->head++;
remain -= chunk;
}
@@ -498,6 +499,7 @@ static inline bool eat_empty_buffer(struct pipe_inode_info *pipe)
unsigned int mask = pipe->ring_size - 1;
struct pipe_buffer *buf = &pipe->bufs[tail & mask];
+ printk("buf: %p, ops: %p, tail: %d %s\n", buf, buf->ops, tail, __func__);
if (unlikely(!buf->len)) {
pipe_buf_release(pipe, buf);
pipe->tail = tail+1;
@@ -755,8 +757,11 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
struct pipe_buffer *buf = &pipe->bufs[tail & mask];
if (ret >= buf->len) {
ret -= buf->len;
- buf->len = 0;
- pipe_buf_release(pipe, buf);
+ printk("buf: %p, ops: %p, buf len: %d, tail: %d, ret: %d, tl: %llu, %s\n", buf, buf->ops, buf->len, tail, ret, sd.total_len, __func__);
+ if (buf->len) {
+ buf->len = 0;
+ pipe_buf_release(pipe, buf);
+ }
tail++;
pipe->tail = tail;
if (pipe->files)
@@ -1483,6 +1488,7 @@ static ssize_t iter_to_pipe(struct iov_iter *from,
put_page(pages[i]);
goto out;
}
+ printk("buf: %p, size: %lu, left: %lu, total: %lu, ret: %lu, %s\n", buf, buf.len, left, total, ret, __func__);
total += ret;
left -= size;
start = 0;