Skip to content

Commit 264db9d

Browse files
t-gianjankara
authored andcommitted
udf: fix uninit-value use in udf_get_fileshortad
Check for overflow when computing alen in udf_current_aext to mitigate later uninit-value use in udf_get_fileshortad KMSAN bug[1]. After applying the patch reproducer did not trigger any issue[2]. [1] https://syzkaller.appspot.com/bug?extid=8901c4560b7ab5c2f9df [2] https://syzkaller.appspot.com/x/log.txt?x=10242227980000 Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=8901c4560b7ab5c2f9df Tested-by: [email protected] Suggested-by: Jan Kara <[email protected]> Signed-off-by: Gianfranco Trad <[email protected]> Signed-off-by: Jan Kara <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent c226964 commit 264db9d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fs/udf/inode.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,12 +2255,15 @@ int udf_current_aext(struct inode *inode, struct extent_position *epos,
22552255
alen = udf_file_entry_alloc_offset(inode) +
22562256
iinfo->i_lenAlloc;
22572257
} else {
2258+
struct allocExtDesc *header =
2259+
(struct allocExtDesc *)epos->bh->b_data;
2260+
22582261
if (!epos->offset)
22592262
epos->offset = sizeof(struct allocExtDesc);
22602263
ptr = epos->bh->b_data + epos->offset;
2261-
alen = sizeof(struct allocExtDesc) +
2262-
le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)->
2263-
lengthAllocDescs);
2264+
if (check_add_overflow(sizeof(struct allocExtDesc),
2265+
le32_to_cpu(header->lengthAllocDescs), &alen))
2266+
return -1;
22642267
}
22652268

22662269
switch (iinfo->i_alloc_type) {

0 commit comments

Comments
 (0)