udf: Validate extended attribute space is large enough

When there is extended attributes space in ICB, there must be at least
enough space for the header of this space. Otherwise the fs is corrupted
and other offset validity checks could underflow.

Reported-by: Lennart Finke <lfinke@student.ethz.ch>
Fixes: 127b0d8764 ("udf: Avoid confusion of missing and corrupted extended attributes")
Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
Jan Kara 2026-10-23 10:41:21 +02:00
parent e21a6f39aa
commit 0415c2624f

View File

@ -1607,6 +1607,11 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
*/
if (iinfo->i_lenEAttr > bs || iinfo->i_lenAlloc > bs)
goto out;
/* We need to have space at least for generic descriptor */
if (iinfo->i_lenEAttr && iinfo->i_lenEAttr <
sizeof(struct extendedAttrHeaderDesc))
goto out;
/* Now do exact checks */
if (udf_file_entry_alloc_offset(inode) + iinfo->i_lenAlloc > bs)
goto out;