mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-11-07 04:09:21 +00:00
udf: Verify symlink size before loading it
commit a1d47b262952a45aae62bd49cfaf33dd76c11a2c upstream. UDF specification allows arbitrarily large symlinks. However we support only symlinks at most one block large. Check the length of the symlink so that we don't access memory beyond end of the symlink block. Reported-by: Carl Henrik Lunde <chlunde@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
12279351a4
commit
5fdeca1b0a
1 changed files with 13 additions and 4 deletions
|
@ -80,11 +80,17 @@ static int udf_symlink_filler(struct file *file, struct page *page)
|
|||
struct inode *inode = page->mapping->host;
|
||||
struct buffer_head *bh = NULL;
|
||||
unsigned char *symlink;
|
||||
int err = -EIO;
|
||||
int err;
|
||||
unsigned char *p = kmap(page);
|
||||
struct udf_inode_info *iinfo;
|
||||
uint32_t pos;
|
||||
|
||||
/* We don't support symlinks longer than one block */
|
||||
if (inode->i_size > inode->i_sb->s_blocksize) {
|
||||
err = -ENAMETOOLONG;
|
||||
goto out_unmap;
|
||||
}
|
||||
|
||||
iinfo = UDF_I(inode);
|
||||
pos = udf_block_map(inode, 0);
|
||||
|
||||
|
@ -94,8 +100,10 @@ static int udf_symlink_filler(struct file *file, struct page *page)
|
|||
} else {
|
||||
bh = sb_bread(inode->i_sb, pos);
|
||||
|
||||
if (!bh)
|
||||
goto out;
|
||||
if (!bh) {
|
||||
err = -EIO;
|
||||
goto out_unlock_inode;
|
||||
}
|
||||
|
||||
symlink = bh->b_data;
|
||||
}
|
||||
|
@ -109,9 +117,10 @@ static int udf_symlink_filler(struct file *file, struct page *page)
|
|||
unlock_page(page);
|
||||
return 0;
|
||||
|
||||
out:
|
||||
out_unlock_inode:
|
||||
up_read(&iinfo->i_data_sem);
|
||||
SetPageError(page);
|
||||
out_unmap:
|
||||
kunmap(page);
|
||||
unlock_page(page);
|
||||
return err;
|
||||
|
|
Loading…
Reference in a new issue