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

From: Edward Adam Davis
Date: Thu May 23 2024 - 08:33:14 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 60aed8de21f8..a38709405e54 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -751,8 +751,16 @@ 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) {
+ n = 0;
+ while (ret > 0 && n < nbufs) {
struct pipe_buffer *buf = &pipe->bufs[tail & mask];
+ printk("ret: %ld, nbufs: %d, buf len: %u, m: %u, t: %u,ring size: %u, t&m: %u, %s\n",
+ ret, nbufs, buf->len, mask, tail, pipe->ring_size, tail & mask, __func__);
+ n++;
+ if (!buf->len) {
+ tail++;
+ continue;
+ }
if (ret >= buf->len) {
ret -= buf->len;
buf->len = 0;