summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorGianfranco Trad <gianf.trad@gmail.com>2025-10-13 16:41:23 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-29 14:01:14 +0100
commit0ce61b1f6b32df822b59c680cbe8e5ba5d335742 (patch)
treef725e432dc831d4dc8a6afecf7ca55208c61c1a1 /fs
parent2871c74caa3f4f05b429e6bfefebac62dbf1b408 (diff)
downloadlinux-0ce61b1f6b32df822b59c680cbe8e5ba5d335742.tar.gz
linux-0ce61b1f6b32df822b59c680cbe8e5ba5d335742.tar.bz2
linux-0ce61b1f6b32df822b59c680cbe8e5ba5d335742.zip
udf: fix uninit-value use in udf_get_fileshortad
[ Upstream commit 264db9d666ad9a35075cc9ed9ec09d021580fbb1 ] 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 Stable-dep-of: 3bd5e45c2ce3 ("fs: udf: fix OOB read in lengthAllocDescs handling") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/udf/inode.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 499a27372a40..f6dbd65b8559 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -2190,12 +2190,15 @@ int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,
alen = udf_file_entry_alloc_offset(inode) +
iinfo->i_lenAlloc;
} else {
+ struct allocExtDesc *header =
+ (struct allocExtDesc *)epos->bh->b_data;
+
if (!epos->offset)
epos->offset = sizeof(struct allocExtDesc);
ptr = epos->bh->b_data + epos->offset;
- alen = sizeof(struct allocExtDesc) +
- le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)->
- lengthAllocDescs);
+ if (check_add_overflow(sizeof(struct allocExtDesc),
+ le32_to_cpu(header->lengthAllocDescs), &alen))
+ return -1;
}
switch (iinfo->i_alloc_type) {