diff options
author | Theodore Ts'o <tytso@mit.edu> | 2018-06-14 19:55:10 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-10-13 10:09:28 +0300 |
commit | 683626073ac0f1ded012d8861b189350147eb86b (patch) | |
tree | 5b0fb6450e3b4c43fea642b1797a753927f7058d /fs/ext4/extents.c | |
parent | d26e09111cb7b9c3727c4621ee241cb408d47a7d (diff) | |
download | linux-683626073ac0f1ded012d8861b189350147eb86b.tar.xz |
ext4: verify the depth of extent tree in ext4_find_extent()
commit bc890a60247171294acc0bd67d211fa4b88d40ba upstream.
If there is a corupted file system where the claimed depth of the
extent tree is -1, this can cause a massive buffer overrun leading to
sadness.
This addresses CVE-2018-10877.
https://bugzilla.kernel.org/show_bug.cgi?id=199417
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
[bwh: Backported to 3.16: return -EIO instead of -EFSCORRUPTED]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index f2f2b86936a5..6dbfa92bf78a 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -870,6 +870,12 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block, eh = ext_inode_hdr(inode); depth = ext_depth(inode); + if (depth < 0 || depth > EXT4_MAX_EXTENT_DEPTH) { + EXT4_ERROR_INODE(inode, "inode has invalid extent depth: %d", + depth); + ret = -EIO; + goto err; + } if (path) { ext4_ext_drop_refs(path); |