Skip to content

Commit d6ab17f

Browse files
committed
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>
1 parent 0891f99 commit d6ab17f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/iomap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,8 @@ iomap_seek_hole(struct inode *inode, loff_t offset, const struct iomap_ops *ops)
610610
loff_t length = size - offset;
611611
loff_t ret;
612612

613-
/* Nothing to be found beyond the end of the file. */
614-
if (offset >= size)
613+
/* Nothing to be found before or beyond the end of the file. */
614+
if (offset < 0 || offset >= size)
615615
return -ENXIO;
616616

617617
while (length > 0) {
@@ -656,8 +656,8 @@ iomap_seek_data(struct inode *inode, loff_t offset, const struct iomap_ops *ops)
656656
loff_t length = size - offset;
657657
loff_t ret;
658658

659-
/* Nothing to be found beyond the end of the file. */
660-
if (offset >= size)
659+
/* Nothing to be found before or beyond the end of the file. */
660+
if (offset < 0 || offset >= size)
661661
return -ENXIO;
662662

663663
while (length > 0) {

0 commit comments

Comments
 (0)