]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
vfs: in iomap seek_{hole,data}, return -ENXIO for negative offsets
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 12 Jul 2017 17:26:47 +0000 (10:26 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Thu, 13 Jul 2017 21:55:05 +0000 (14:55 -0700)
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>
fs/iomap.c

index 432eed8f091f171d479c4c7174269c4a62d61e6b..16f5c07451bf48e4164528e54bf9289c565ab111 100644 (file)
@@ -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) {