summaryrefslogtreecommitdiffstats
path: root/fs/iomap.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2017-07-12 10:26:47 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2017-07-13 14:55:05 -0700
commitd6ab17f261919d212ec0a9e33d01f46df0ec1fde (patch)
tree185ec0d398285b1c444df1de3f109860b000f3f5 /fs/iomap.c
parent0891f9971a3b00d243d5743cc78a628ad060adea (diff)
downloadlinux-d6ab17f261919d212ec0a9e33d01f46df0ec1fde.tar.bz2
vfs: in iomap seek_{hole,data}, return -ENXIO for negative offsets
In the iomap implementations of SEEK_HOLE and SEEK_DATA, make sure we return -ENXIO for negative offsets. Inspired-by: Mateusz S <muttdini@gmail.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/iomap.c')
-rw-r--r--fs/iomap.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/iomap.c b/fs/iomap.c
index 432eed8f091f..16f5c07451bf 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -610,8 +610,8 @@ iomap_seek_hole(struct inode *inode, loff_t offset, const struct iomap_ops *ops)
loff_t length = size - offset;
loff_t ret;
- /* Nothing to be found beyond the end of the file. */
- if (offset >= size)
+ /* Nothing to be found before or beyond the end of the file. */
+ if (offset < 0 || offset >= size)
return -ENXIO;
while (length > 0) {
@@ -656,8 +656,8 @@ iomap_seek_data(struct inode *inode, loff_t offset, const struct iomap_ops *ops)
loff_t length = size - offset;
loff_t ret;
- /* Nothing to be found beyond the end of the file. */
- if (offset >= size)
+ /* Nothing to be found before or beyond the end of the file. */
+ if (offset < 0 || offset >= size)
return -ENXIO;
while (length > 0) {