Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00a2b0f6 authored by Jan Kara's avatar Jan Kara Committed by Greg Kroah-Hartman
Browse files

Fix possible UDF deadlock and memory corruption (CVE-2006-4145)



UDF code is not really ready to handle extents larger that 1GB. This is
the easy way to forbid creating those.

Also truncation code did not count with the case when there are no
extents in the file and we are extending the file.

Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c164a9ba
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1659,7 +1659,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
		iput(inode);
		iput(inode);
		goto error_out;
		goto error_out;
	}
	}
	sb->s_maxbytes = MAX_LFS_FILESIZE;
	sb->s_maxbytes = 1<<30;
	return 0;
	return 0;


error_out:
error_out:
+39 −25
Original line number Original line Diff line number Diff line
@@ -239,6 +239,19 @@ void udf_truncate_extents(struct inode * inode)
	{
	{
		if (offset)
		if (offset)
		{
		{
			/*
			 *  OK, there is not extent covering inode->i_size and
			 *  no extent above inode->i_size => truncate is
			 *  extending the file by 'offset'.
			 */
			if ((!bh && extoffset == udf_file_entry_alloc_offset(inode)) ||
			    (bh && extoffset == sizeof(struct allocExtDesc))) {
				/* File has no extents at all! */
				memset(&eloc, 0x00, sizeof(kernel_lb_addr));
				elen = EXT_NOT_RECORDED_NOT_ALLOCATED | offset;
				udf_add_aext(inode, &bloc, &extoffset, eloc, elen, &bh, 1);
			}
			else {
				extoffset -= adsize;
				extoffset -= adsize;
				etype = udf_next_aext(inode, &bloc, &extoffset, &eloc, &elen, &bh, 1);
				etype = udf_next_aext(inode, &bloc, &extoffset, &eloc, &elen, &bh, 1);
				if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))
				if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))
@@ -273,6 +286,7 @@ void udf_truncate_extents(struct inode * inode)
				}
				}
			}
			}
		}
		}
	}
	UDF_I_LENEXTENTS(inode) = inode->i_size;
	UDF_I_LENEXTENTS(inode) = inode->i_size;


	udf_release_data(bh);
	udf_release_data(bh);