Skip to content

Commit 9d99995

Browse files
mywave82gregkh
authored andcommitted
udf_get_extendedattr() had no boundary checks.
[ Upstream commit 58bc6d1 ] When parsing the ExtendedAttr data, malicous or corrupt attribute length could cause kernel hangs and buffer overruns in some special cases. Link: https://lore.kernel.org/r/20210822093332.25234-1-stian.skjelstad@gmail.com Signed-off-by: Stian Skjelstad <stian.skjelstad@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent db2f238 commit 9d99995

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎fs/udf/misc.c‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,22 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
173173
else
174174
offset = le32_to_cpu(eahd->appAttrLocation);
175175

176-
while (offset < iinfo->i_lenEAttr) {
176+
while (offset + sizeof(*gaf) < iinfo->i_lenEAttr) {
177+
uint32_t attrLength;
178+
177179
gaf = (struct genericFormat *)&ea[offset];
180+
attrLength = le32_to_cpu(gaf->attrLength);
181+
182+
/* Detect undersized elements and buffer overflows */
183+
if ((attrLength < sizeof(*gaf)) ||
184+
(attrLength > (iinfo->i_lenEAttr - offset)))
185+
break;
186+
178187
if (le32_to_cpu(gaf->attrType) == type &&
179188
gaf->attrSubtype == subtype)
180189
return gaf;
181190
else
182-
offset += le32_to_cpu(gaf->attrLength);
191+
offset += attrLength;
183192
}
184193
}
185194

0 commit comments

Comments
 (0)