Blob Blame History Raw
From 2c5773f102c9bb07d5328467f61f0a88f2f2892d Mon Sep 17 00:00:00 2001
From: "Darrick J. Wong" <darrick.wong@oracle.com>
Date: Tue, 30 Oct 2018 10:40:39 +1100
Subject: [PATCH] vfs: exit early from zero length remap operations
Git-commit: 2c5773f102c9bb07d5328467f61f0a88f2f2892d
Patch-mainline: v4.20-rc1
References: bsc#1132411, bsc#1132219

If a remap caller asks us to remap to the source file's EOF and the
source file length leaves us with a zero byte request, exit early.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>

---
 fs/read_write.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1760,6 +1760,8 @@
 		if (pos_in > isize)
 			return -EINVAL;
 		*len = isize - pos_in;
+		if (*len == 0)
+			return 0;
 	}
 
 	/* Ensure offsets don't wrap and the input is inside i_size */