diff mbox series

vfs: fix early copy_file_range return when len is zero

Message ID 20210518111055.16079-1-lhenriques@suse.de (mailing list archive)
State New, archived
Headers show
Series vfs: fix early copy_file_range return when len is zero | expand

Commit Message

Luis Henriques May 18, 2021, 11:10 a.m. UTC
The early return from copy_file_range when len is zero should check if the
filesystem really implements this syscall, returning -EOPNOTSUPP if it doesn't,
and 0 otherwise.

Reported-by: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Luis Henriques <lhenriques@suse.de>
---
Hi!

Since I got not feedback, I'm sending a patch that should fix this issue
reported by 0day.  Probably this should simply be squashed into v9, I can
send v10 if you prefer that.

Cheers,
--
Luis

 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/read_write.c b/fs/read_write.c
index 9db7adf160d2..24b4bf704765 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1498,7 +1498,7 @@  ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in,
 		return ret;
 
 	if (len == 0)
-		return 0;
+		return file_out->f_op->copy_file_range ? 0 : -EOPNOTSUPP;
 
 	file_start_write(file_out);