Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933291AbZAOUwX (ORCPT ); Thu, 15 Jan 2009 15:52:23 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932238AbZAOUCw (ORCPT ); Thu, 15 Jan 2009 15:02:52 -0500 Received: from kroah.org ([198.145.64.141]:49786 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932330AbZAOUCv (ORCPT ); Thu, 15 Jan 2009 15:02:51 -0500 Date: Thu, 15 Jan 2009 12:00:29 -0800 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org Cc: Justin Forbes , Zwane Mwaikambo , "Theodore Ts'o" , Randy Dunlap , Dave Jones , Chuck Wolber , Chris Wedgwood , Michael Krufky , Chuck Ebbert , Domenico Andreoli , Willy Tarreau , Rodrigo Rubira Branco , Jake Edge , Eugene Teo , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Tyler Hicks , Dustin Kirkland , ecryptfs-devel@lists.launchpad.net, Duane Griffin , Michael Halcrow , Al Viro Subject: [patch 84/94] eCryptfs: check readlink result was not an error before using it Message-ID: <20090115200029.GF14419@kroah.com> References: <20090115194806.804618825@mini.kroah.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="ecryptfs-check-readlink-result-was-not-an-error-before-using-it.patch" In-Reply-To: <20090115195520.GA14403@kroah.com> User-Agent: Mutt/1.5.16 (2007-06-09) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1541 Lines: 46 2.6.28-stable review patch. If anyone has any objections, please let us know. ------------------ From: Duane Griffin commit a17d5232de7b53d34229de79ec22f4bb04adb7e4 upstream. The result from readlink is being used to index into the link name buffer without checking whether it is a valid length. If readlink returns an error this will fault or cause memory corruption. Cc: Tyler Hicks Cc: Dustin Kirkland Cc: ecryptfs-devel@lists.launchpad.net Signed-off-by: Duane Griffin Acked-by: Michael Halcrow Acked-by: Tyler Hicks Signed-off-by: Al Viro Signed-off-by: Greg Kroah-Hartman --- fs/ecryptfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -673,10 +673,11 @@ static void *ecryptfs_follow_link(struct ecryptfs_printk(KERN_DEBUG, "Calling readlink w/ " "dentry->d_name.name = [%s]\n", dentry->d_name.name); rc = dentry->d_inode->i_op->readlink(dentry, (char __user *)buf, len); - buf[rc] = '\0'; set_fs(old_fs); if (rc < 0) goto out_free; + else + buf[rc] = '\0'; rc = 0; nd_set_link(nd, buf); goto out; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/