udf: Limit sparing table size
authorJan Kara <jack@suse.cz>
Fri, 25 Sep 2020 12:53:08 +0000 (14:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 08:05:44 +0000 (09:05 +0100)
[ Upstream commit 44ac6b829c4e173fdf6df18e6dd86aecf9a3dc99 ]

Although UDF standard allows it, we don't support sparing table larger
than a single block. Check it during mount so that we don't try to
access memory beyond end of buffer.

Reported-by: syzbot+9991561e714f597095da@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/udf/super.c

index 4abdba4..c8c037e 100644 (file)
@@ -1391,6 +1391,12 @@ static int udf_load_sparable_map(struct super_block *sb,
                        (int)spm->numSparingTables);
                return -EIO;
        }
+       if (le32_to_cpu(spm->sizeSparingTable) > sb->s_blocksize) {
+               udf_err(sb, "error loading logical volume descriptor: "
+                       "Too big sparing table size (%u)\n",
+                       le32_to_cpu(spm->sizeSparingTable));
+               return -EIO;
+       }
 
        for (i = 0; i < spm->numSparingTables; i++) {
                loc = le32_to_cpu(spm->locSparingTable[i]);