From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Cheng Yongkang <teel4res@gmail.com>,
"Christian Brauner (Amutable)" <brauner@kernel.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6.y] fs/splice: clamp an over-reported write_iter result
Date: Wed, 25 Nov 2026 11:13:44 -0500 [thread overview]
Message-ID: <20261125161326.718366-1-sashal@kernel.org> (raw)
In-Reply-To: <2026112545-provider-relock-0116@gregkh>
From: Cheng Yongkang <teel4res@gmail.com>
[ Upstream commit 2d956723e82cddae8ff8e9da99a666217b02065f ]
iter_file_splice_write() builds a bvec iterator of at most
sd.total_len - left bytes and passes it to ->write_iter(). It then
subtracts the returned length from sd.total_len and walks the pipe
buffers by that length. A ->write_iter() implementation that reports
more bytes than the iterator held makes sd.total_len underflow and the
dismissal loop advance pipe->tail past pipe->head, releasing a zeroed
pipe buffer:
Splice Exceeded! ret=7 tot=1 left=0
Oops: general protection fault
RIP: 0010:iter_file_splice_write+0xb6f/0x1170
Commit a3de58b12ce0 ("netfs: Fix unbuffered write error handling")
added the warning for this condition but only reports it. Clamp the
return value to the size of the iterator that was actually handed to
->write_iter(), so the pipe accounting stays consistent even when a
producer violates the iterator contract.
Fixes: 8d0207652cbe ("->splice_write() via ->write_iter()")
Cc: stable@vger.kernel.org
Signed-off-by: Cheng Yongkang <teel4res@gmail.com>
Link: https://patch.msgid.link/179328314072.648427.13388575162083843840@gmail.com
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
[ sashal: Added the over-reported write_iter clamp as a standalone block, since the context lacked the existing WARN_ONCE line that upstream rewrites. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/splice.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/splice.c b/fs/splice.c
index 63d37481baa25..c673b31324c3e 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -736,6 +736,12 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
ret = vfs_iter_write(out, &from, &sd.pos, 0);
if (ret <= 0)
break;
+ if (unlikely(ret > sd.total_len - left)) {
+ WARN_ONCE(1,
+ "Splice Exceeded! ret=%zd tot=%zu left=%zu\n",
+ ret, sd.total_len, left);
+ ret = sd.total_len - left;
+ }
sd.num_spliced += ret;
sd.total_len -= ret;
--
2.53.0
prev parent reply other threads:[~2026-11-25 16:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 9:20 FAILED: patch "[PATCH] fs/splice: clamp an over-reported write_iter result" failed to apply to 6.6-stable tree gregkh
2026-11-25 16:13 ` Sasha Levin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125161326.718366-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=brauner@kernel.org \
--cc=stable@vger.kernel.org \
--cc=teel4res@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox