* [PATCH] fs: allow sendfile EOF at the file size limit
@ 2026-10-27 4:42 Hungyu Lin
0 siblings, 0 replies; only message in thread
From: Hungyu Lin @ 2026-10-27 4:42 UTC (permalink / raw)
To: brauner, viro; +Cc: jack, linux-fsdevel, linux-kernel, dennylin0707
do_sendfile() returns EOVERFLOW when a positive-count request starts
at the effective file size limit. If the input file ends exactly at
that limit, this rejects the final EOF probe even though no bytes
remain to be copied.
For example, Python 3.12 shutil.copyfile() copies all 4294967295 bytes
of a maximum-size FAT32 file to ext4, then raises EOVERFLOW on its
next sendfile() call instead of completing successfully.
Allow the boundary position when it matches the input file size. The
existing clamp then reduces count to zero and the remaining validation
is retained. Continue to reject positions beyond the limit and boundary
positions with input data still remaining.
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
fs/read_write.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/read_write.c b/fs/read_write.c
index 4da846a2bf17..a25e23c6a327 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1347,7 +1347,8 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
max = min(in_inode->i_sb->s_maxbytes, out_inode->i_sb->s_maxbytes);
if (unlikely(pos + count > max)) {
- if (pos >= max)
+ if (pos > max ||
+ (pos == max && pos != i_size_read(in_inode)))
return -EOVERFLOW;
count = max - pos;
}
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-27 4:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 4:42 [PATCH] fs: allow sendfile EOF at the file size limit Hungyu Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®