From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932206AbbILXPQ (ORCPT ); Sat, 12 Sep 2015 19:15:16 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:9382 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755524AbbILXNW (ORCPT ); Sat, 12 Sep 2015 19:13:22 -0400 Message-Id: <20150912225606.957401547@1wt.eu> User-Agent: quilt/0.63-1 Date: Sun, 13 Sep 2015 00:56:15 +0200 From: Willy Tarreau To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Carl Henrik Lunde , Jan Kara , Ben Hutchings , Willy Tarreau Subject: [PATCH 2.6.32 09/62] udf: Verify symlink size before loading it MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 In-Reply-To: <08d3b586eb2e764308c3de9ee398a17c@local> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2.6.32-longterm review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara 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 Signed-off-by: Jan Kara [bwh: Backported to 2.6.32: adjust context] Signed-off-by: Ben Hutchings CVE-2014-9728 Signed-off-by: Willy Tarreau --- fs/udf/symlink.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c index c3265e1..e28a902 100644 --- a/fs/udf/symlink.c +++ b/fs/udf/symlink.c @@ -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; -- 1.7.12.2.21.g234cd45.dirty