Skip to content

Commit a17d523

Browse files
duanegAl Viro
authored andcommitted
eCryptfs: check readlink result was not an error before using it
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 <tyhicks@linux.vnet.ibm.com> Cc: Dustin Kirkland <kirkland@canonical.com> Cc: ecryptfs-devel@lists.launchpad.net Signed-off-by: Duane Griffin <duaneg@dghda.com> Acked-by: Michael Halcrow <mhalcrow@us.ibm.com> Acked-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 5cc4a03 commit a17d523

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎fs/ecryptfs/inode.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,11 @@ static void *ecryptfs_follow_link(struct dentry *dentry, struct nameidata *nd)
673673
ecryptfs_printk(KERN_DEBUG, "Calling readlink w/ "
674674
"dentry->d_name.name = [%s]\n", dentry->d_name.name);
675675
rc = dentry->d_inode->i_op->readlink(dentry, (char __user *)buf, len);
676-
buf[rc] = '\0';
677676
set_fs(old_fs);
678677
if (rc < 0)
679678
goto out_free;
679+
else
680+
buf[rc] = '\0';
680681
rc = 0;
681682
nd_set_link(nd, buf);
682683
goto out;

0 commit comments

Comments
 (0)