]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.93/ext4-in-ext4_seek_-hole-data-return-enxio-for-negative-offsets.patch
5.0-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.93 / ext4-in-ext4_seek_-hole-data-return-enxio-for-negative-offsets.patch
1 From 1bd8d6cd3e413d64e543ec3e69ff43e75a1cf1ea Mon Sep 17 00:00:00 2001
2 From: "Darrick J. Wong" <darrick.wong@oracle.com>
3 Date: Thu, 24 Aug 2017 13:22:06 -0400
4 Subject: ext4: in ext4_seek_{hole,data}, return -ENXIO for negative offsets
5
6 From: Darrick J. Wong <darrick.wong@oracle.com>
7
8 commit 1bd8d6cd3e413d64e543ec3e69ff43e75a1cf1ea upstream.
9
10 In the ext4 implementations of SEEK_HOLE and SEEK_DATA, make sure we
11 return -ENXIO for negative offsets instead of banging around inside
12 the extent code and returning -EFSCORRUPTED.
13
14 Reported-by: Mateusz S <muttdini@gmail.com>
15 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
16 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18
19 ---
20 fs/ext4/file.c | 4 ++--
21 1 file changed, 2 insertions(+), 2 deletions(-)
22
23 --- a/fs/ext4/file.c
24 +++ b/fs/ext4/file.c
25 @@ -559,7 +559,7 @@ static loff_t ext4_seek_data(struct file
26 mutex_lock(&inode->i_mutex);
27
28 isize = i_size_read(inode);
29 - if (offset >= isize) {
30 + if (offset < 0 || offset >= isize) {
31 mutex_unlock(&inode->i_mutex);
32 return -ENXIO;
33 }
34 @@ -632,7 +632,7 @@ static loff_t ext4_seek_hole(struct file
35 mutex_lock(&inode->i_mutex);
36
37 isize = i_size_read(inode);
38 - if (offset >= isize) {
39 + if (offset < 0 || offset >= isize) {
40 mutex_unlock(&inode->i_mutex);
41 return -ENXIO;
42 }