]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
udf: Verify symlink size before loading it
authorJan Kara <jack@suse.cz>
Fri, 19 Dec 2014 11:21:47 +0000 (12:21 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Sep 2015 11:51:54 +0000 (13:51 +0200)
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>
[bwh: Backported to 2.6.32: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
CVE-2014-9728

Signed-off-by: Willy Tarreau <w@1wt.eu>
fs/udf/symlink.c

index c3265e1385d43c5c6ed0e2960cf9d83a72493e4a..e28a9024eeada88f44178c56a3fa6e603d8cf20d 100644 (file)
@@ -76,10 +76,16 @@ static int udf_symlink_filler(struct file *file, struct page *page)
        struct inode *inode = page->mapping->host;
        struct buffer_head *bh = NULL;
        char *symlink;
-       int err = -EIO;
+       int err;
        char *p = kmap(page);
        struct udf_inode_info *iinfo;
 
+       /* We don't support symlinks longer than one block */
+       if (inode->i_size > inode->i_sb->s_blocksize) {
+               err = -ENAMETOOLONG;
+               goto out_unmap;
+       }
+
        lock_kernel();
        iinfo = UDF_I(inode);
        if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
@@ -87,8 +93,10 @@ static int udf_symlink_filler(struct file *file, struct page *page)
        } else {
                bh = sb_bread(inode->i_sb, udf_block_map(inode, 0));
 
-               if (!bh)
-                       goto out;
+               if (!bh) {
+                       err = -EIO;
+                       goto out_unlock_inode;
+               }
 
                symlink = bh->b_data;
        }
@@ -102,9 +110,10 @@ static int udf_symlink_filler(struct file *file, struct page *page)
        unlock_page(page);
        return 0;
 
-out:
+out_unlock_inode:
        unlock_kernel();
        SetPageError(page);
+out_unmap:
        kunmap(page);
        unlock_page(page);
        return err;