Skip to content

Commit 1bd8d6c

Browse files
djwongtytso
authored andcommitted
ext4: in ext4_seek_{hole,data}, return -ENXIO for negative offsets
In the ext4 implementations of SEEK_HOLE and SEEK_DATA, make sure we return -ENXIO for negative offsets instead of banging around inside the extent code and returning -EFSCORRUPTED. Reported-by: Mateusz S <muttdini@gmail.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@vger.kernel.org # 4.6
1 parent 901ed07 commit 1bd8d6c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎fs/ext4/file.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ static loff_t ext4_seek_data(struct file *file, loff_t offset, loff_t maxsize)
595595
inode_lock(inode);
596596

597597
isize = i_size_read(inode);
598-
if (offset >= isize) {
598+
if (offset < 0 || offset >= isize) {
599599
inode_unlock(inode);
600600
return -ENXIO;
601601
}
@@ -658,7 +658,7 @@ static loff_t ext4_seek_hole(struct file *file, loff_t offset, loff_t maxsize)
658658
inode_lock(inode);
659659

660660
isize = i_size_read(inode);
661-
if (offset >= isize) {
661+
if (offset < 0 || offset >= isize) {
662662
inode_unlock(inode);
663663
return -ENXIO;
664664
}

0 commit comments

Comments
 (0)