mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 23:53:32 +00:00
udf_get_extendedattr() had no boundary checks.
[ Upstream commit 58bc6d1be2
]
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>
This commit is contained in:
parent
db2f238d8d
commit
9d999957cb
1 changed files with 11 additions and 2 deletions
|
@ -173,13 +173,22 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
|
|||
else
|
||||
offset = le32_to_cpu(eahd->appAttrLocation);
|
||||
|
||||
while (offset < iinfo->i_lenEAttr) {
|
||||
while (offset + sizeof(*gaf) < iinfo->i_lenEAttr) {
|
||||
uint32_t attrLength;
|
||||
|
||||
gaf = (struct genericFormat *)&ea[offset];
|
||||
attrLength = le32_to_cpu(gaf->attrLength);
|
||||
|
||||
/* Detect undersized elements and buffer overflows */
|
||||
if ((attrLength < sizeof(*gaf)) ||
|
||||
(attrLength > (iinfo->i_lenEAttr - offset)))
|
||||
break;
|
||||
|
||||
if (le32_to_cpu(gaf->attrType) == type &&
|
||||
gaf->attrSubtype == subtype)
|
||||
return gaf;
|
||||
else
|
||||
offset += le32_to_cpu(gaf->attrLength);
|
||||
offset += attrLength;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue