Skip to contentSkip to conversation

vfs: generic_copy_file_checks should return EINVAL when source offset is beyond EOF

PATCH Superseded Dai Ngo 1 participant 1 message Feb 1, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Dai Ngo

author reviewer
#0 lore raw

PATCH 1/1 vfs: generic_copy_file_checks should return EINVAL when source offset is beyond EOF

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.

---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/read_write.c +1 -1
index 75f764b43418..438c00910716 100644
@@ -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);
 
Signature · 1 line
2.9.5