Commit 78a198ac authored by Jan Kara's avatar Jan Kara Committed by Kamal Mostafa

udf: Remove repeated loads blocksize

commit 79144954 upstream.

Store blocksize in a local variable in udf_fill_inode() since it is used
a lot of times.
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Reference: CVE-2015-4167
BugLink: https://bugs.launchpad.net/bugs/1462173
[ luis: used Ben's backport to 3.16: adjusted context ]
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent 267d8362
...@@ -1286,6 +1286,7 @@ static void __udf_read_inode(struct inode *inode) ...@@ -1286,6 +1286,7 @@ static void __udf_read_inode(struct inode *inode)
struct udf_sb_info *sbi = UDF_SB(inode->i_sb); struct udf_sb_info *sbi = UDF_SB(inode->i_sb);
unsigned int link_count; unsigned int link_count;
unsigned int indirections = 0; unsigned int indirections = 0;
int bs = inode->i_sb->s_blocksize;
reread: reread:
/* /*
...@@ -1371,41 +1372,38 @@ static void __udf_read_inode(struct inode *inode) ...@@ -1371,41 +1372,38 @@ static void __udf_read_inode(struct inode *inode)
if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_EFE)) { if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_EFE)) {
iinfo->i_efe = 1; iinfo->i_efe = 1;
iinfo->i_use = 0; iinfo->i_use = 0;
if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - if (udf_alloc_i_data(inode, bs -
sizeof(struct extendedFileEntry))) { sizeof(struct extendedFileEntry))) {
make_bad_inode(inode); make_bad_inode(inode);
return; return;
} }
memcpy(iinfo->i_ext.i_data, memcpy(iinfo->i_ext.i_data,
bh->b_data + sizeof(struct extendedFileEntry), bh->b_data + sizeof(struct extendedFileEntry),
inode->i_sb->s_blocksize - bs - sizeof(struct extendedFileEntry));
sizeof(struct extendedFileEntry));
} else if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_FE)) { } else if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_FE)) {
iinfo->i_efe = 0; iinfo->i_efe = 0;
iinfo->i_use = 0; iinfo->i_use = 0;
if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - if (udf_alloc_i_data(inode, bs - sizeof(struct fileEntry))) {
sizeof(struct fileEntry))) {
make_bad_inode(inode); make_bad_inode(inode);
return; return;
} }
memcpy(iinfo->i_ext.i_data, memcpy(iinfo->i_ext.i_data,
bh->b_data + sizeof(struct fileEntry), bh->b_data + sizeof(struct fileEntry),
inode->i_sb->s_blocksize - sizeof(struct fileEntry)); bs - sizeof(struct fileEntry));
} else if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_USE)) { } else if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_USE)) {
iinfo->i_efe = 0; iinfo->i_efe = 0;
iinfo->i_use = 1; iinfo->i_use = 1;
iinfo->i_lenAlloc = le32_to_cpu( iinfo->i_lenAlloc = le32_to_cpu(
((struct unallocSpaceEntry *)bh->b_data)-> ((struct unallocSpaceEntry *)bh->b_data)->
lengthAllocDescs); lengthAllocDescs);
if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - if (udf_alloc_i_data(inode, bs -
sizeof(struct unallocSpaceEntry))) { sizeof(struct unallocSpaceEntry))) {
make_bad_inode(inode); make_bad_inode(inode);
return; return;
} }
memcpy(iinfo->i_ext.i_data, memcpy(iinfo->i_ext.i_data,
bh->b_data + sizeof(struct unallocSpaceEntry), bh->b_data + sizeof(struct unallocSpaceEntry),
inode->i_sb->s_blocksize - bs - sizeof(struct unallocSpaceEntry));
sizeof(struct unallocSpaceEntry));
return; return;
} }
...@@ -1493,8 +1491,7 @@ static void __udf_read_inode(struct inode *inode) ...@@ -1493,8 +1491,7 @@ static void __udf_read_inode(struct inode *inode)
return; return;
} }
/* File in ICB has to fit in there... */ /* File in ICB has to fit in there... */
if (inode->i_size > inode->i_sb->s_blocksize - if (inode->i_size > bs - udf_file_entry_alloc_offset(inode)) {
udf_file_entry_alloc_offset(inode)) {
make_bad_inode(inode); make_bad_inode(inode);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment