Skip to content

Commit 5eb76fb

Browse files
t-giangregkh
authored andcommitted
udf: fix uninit-value use in udf_get_fileshortad
[ Upstream commit 264db9d ] 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: syzbot+8901c4560b7ab5c2f9df@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=8901c4560b7ab5c2f9df Tested-by: syzbot+8901c4560b7ab5c2f9df@syzkaller.appspotmail.com Suggested-by: Jan Kara <jack@suse.com> Signed-off-by: Gianfranco Trad <gianf.trad@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz> Link: https://patch.msgid.link/20240925074613.8475-3-gianf.trad@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent c6c7018 commit 5eb76fb

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
@@ -2166,12 +2166,15 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,
21662166
alen = udf_file_entry_alloc_offset(inode) +
21672167
iinfo->i_lenAlloc;
21682168
} else {
2169+
struct allocExtDesc *header =
2170+
(struct allocExtDesc *)epos->bh->b_data;
2171+
21692172
if (!epos->offset)
21702173
epos->offset = sizeof(struct allocExtDesc);
21712174
ptr = epos->bh->b_data + epos->offset;
2172-
alen = sizeof(struct allocExtDesc) +
2173-
le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)->
2174-
lengthAllocDescs);
2175+
if (check_add_overflow(sizeof(struct allocExtDesc),
2176+
le32_to_cpu(header->lengthAllocDescs), &alen))
2177+
return -1;
21752178
}
21762179

21772180
switch (iinfo->i_alloc_type) {

0 commit comments

Comments
 (0)