linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfs: generic_copy_file_checks should return EINVAL when source offset is beyond EOF
@ 2021-02-01 20:47 Dai Ngo
  0 siblings, 0 replies; only message in thread
From: Dai Ngo @ 2021-02-01 20:47 UTC (permalink / raw)
  To: linux-fsdevel, linux-nfs

Fix by returning -EINVAL instead of 0, per man page of copy_file_range,
when the requested range extends beyond the end of the source file.
Probem was discovered by subtest inter11 of nfstest_ssc.

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 75f764b43418..438c00910716 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1445,7 +1445,7 @@ static int generic_copy_file_checks(struct file *file_in, loff_t pos_in,
 	/* Shorten the copy to EOF */
 	size_in = i_size_read(inode_in);
 	if (pos_in >= size_in)
-		count = 0;
+		count = -EINVAL;
 	else
 		count = min(count, size_in - (uint64_t)pos_in);
 
-- 
2.9.5


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-01 20:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 20:47 [PATCH] vfs: generic_copy_file_checks should return EINVAL when source offset is beyond EOF Dai Ngo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).