From patchwork Tue Sep 13 15:21:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Whitcroft X-Patchwork-Id: 114507 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 1DDC3B71D0 for ; Wed, 14 Sep 2011 01:22:04 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1R3Uny-0006ZG-4O; Tue, 13 Sep 2011 15:21:46 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1R3Ung-0006Ox-TW for kernel-team@lists.ubuntu.com; Tue, 13 Sep 2011 15:21:28 +0000 Received: from 212-139-214-120.dynamic.dsl.as9105.com ([212.139.214.120] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1R3Ung-0000YN-Q5 for kernel-team@lists.ubuntu.com; Tue, 13 Sep 2011 15:21:28 +0000 From: Andy Whitcroft To: kernel-team@lists.ubuntu.com Subject: [hardy CVE 1/2] befs: ensure fast symlinks are NUL-terminated Date: Tue, 13 Sep 2011 16:21:24 +0100 Message-Id: <1315927286-24322-2-git-send-email-apw@canonical.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1315927286-24322-1-git-send-email-apw@canonical.com> References: <1315927286-24322-1-git-send-email-apw@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: Duane Griffin Ensure fast symlink targets are NUL-terminated, even if corrupted on-disk. Cc: Sergey S. Kostyliov Signed-off-by: Duane Griffin Signed-off-by: Al Viro (cherry picked from commit 7df5fa06de89a4ac311957e0cb9c1d87552b4325) CVE-2011-2928 BugLink: http://bugs.launchpad.net/bugs/834124 Signed-off-by: Andy Whitcroft --- fs/befs/linuxvfs.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index b28a20e..2c7fa86 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -371,7 +371,8 @@ befs_read_inode(struct inode *inode) inode->i_size = 0; inode->i_blocks = befs_sb->block_size / VFS_BLOCK_SIZE; strncpy(befs_ino->i_data.symlink, raw_inode->data.symlink, - BEFS_SYMLINK_LEN); + BEFS_SYMLINK_LEN - 1); + befs_ino->i_data.symlink[BEFS_SYMLINK_LEN - 1] = '\0'; } else { int num_blks; @@ -469,6 +470,8 @@ befs_follow_link(struct dentry *dentry, struct nameidata *nd) kfree(link); befs_error(sb, "Failed to read entire long symlink"); link = ERR_PTR(-EIO); + } else { + link[len - 1] = '\0'; } } else { link = befs_ino->i_data.symlink;