Skip to content

Commit 417bd61

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 02c86c5 commit 417bd61

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
@@ -2193,12 +2193,15 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,
21932193
alen = udf_file_entry_alloc_offset(inode) +
21942194
iinfo->i_lenAlloc;
21952195
} else {
2196+
struct allocExtDesc *header =
2197+
(struct allocExtDesc *)epos->bh->b_data;
2198+
21962199
if (!epos->offset)
21972200
epos->offset = sizeof(struct allocExtDesc);
21982201
ptr = epos->bh->b_data + epos->offset;
2199-
alen = sizeof(struct allocExtDesc) +
2200-
le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)->
2201-
lengthAllocDescs);
2202+
if (check_add_overflow(sizeof(struct allocExtDesc),
2203+
le32_to_cpu(header->lengthAllocDescs), &alen))
2204+
return -1;
22022205
}
22032206

22042207
switch (iinfo->i_alloc_type) {

0 commit comments

Comments
 (0)