Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Darrick J. Wong and committed by
Theodore Ts'o
1bd8d6cd 901ed070

+2 -2
+2 -2
fs/ext4/file.c
··· 595 595 inode_lock(inode); 596 596 597 597 isize = i_size_read(inode); 598 - if (offset >= isize) { 598 + if (offset < 0 || offset >= isize) { 599 599 inode_unlock(inode); 600 600 return -ENXIO; 601 601 } ··· 658 658 inode_lock(inode); 659 659 660 660 isize = i_size_read(inode); 661 - if (offset >= isize) { 661 + if (offset < 0 || offset >= isize) { 662 662 inode_unlock(inode); 663 663 return -ENXIO; 664 664 }