Skip to content

Commit

Permalink
eCryptfs: check readlink result was not an error before using it
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Dustin Kirkland <[email protected]>
Cc: [email protected]
Signed-off-by: Duane Griffin <[email protected]>
Acked-by: Michael Halcrow <[email protected]>
Acked-by: Tyler Hicks <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
duaneg authored and Al Viro committed Dec 31, 2008
1 parent 5cc4a03 commit a17d523
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/ecryptfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,11 @@ static void *ecryptfs_follow_link(struct dentry *dentry, struct nameidata *nd)
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;
Expand Down

0 comments on commit a17d523

Please sign in to comment.