From: Jan Kara Date: Wed, 12 Dec 2018 13:29:20 +0000 (+0100) Subject: udf: Fix BUG on corrupted inode X-Git-Tag: rel_imx_5.10.35_2.0.0-somdevices.0~5657^2~1 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=d288d95842f1503414b7eebce3773bac3390457e;p=linux.git udf: Fix BUG on corrupted inode When inode is corrupted so that extent type is invalid, some functions (such as udf_truncate_extents()) will just BUG. Check that extent type is valid when loading the inode to memory. Reported-by: Anatoly Trosinenko Signed-off-by: Jan Kara --- diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 5df554a9f9c9..ae796e10f68b 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -1357,6 +1357,12 @@ reread: iinfo->i_alloc_type = le16_to_cpu(fe->icbTag.flags) & ICBTAG_FLAG_AD_MASK; + if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_SHORT && + iinfo->i_alloc_type != ICBTAG_FLAG_AD_LONG && + iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { + ret = -EIO; + goto out; + } iinfo->i_unique = 0; iinfo->i_lenEAttr = 0; iinfo->i_lenExtents = 0;