From: Jan Kara Date: Wed, 13 Jun 2018 10:09:22 +0000 (+0200) Subject: udf: Detect incorrect directory size X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1b241aa840df5c7af16eb1ad0b614a372a639caa;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git udf: Detect incorrect directory size commit fa65653e575fbd958bdf5fb9c4a71a324e39510d upstream. Detect when a directory entry is (possibly partially) beyond directory size and return EIO in that case since it means the filesystem is corrupted. Otherwise directory operations can further corrupt the directory and possibly also oops the kernel. CC: Anatoly Trosinenko CC: stable@vger.kernel.org Reported-and-tested-by: Anatoly Trosinenko Signed-off-by: Jan Kara Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/udf/directory.c b/fs/udf/directory.c index 7aa48bd7cbaf..a636b3b17219 100644 --- a/fs/udf/directory.c +++ b/fs/udf/directory.c @@ -151,6 +151,9 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos, sizeof(struct fileIdentDesc)); } } + /* Got last entry outside of dir size - fs is corrupted! */ + if (*nf_pos > dir->i_size) + return NULL; return fi; }