Skip to content

Commit

Permalink
vfs: ensure page symlinks are NUL-terminated
Browse files Browse the repository at this point in the history
On-disk data corruption could cause a page link to have its i_size set
to PAGE_SIZE (or a multiple thereof) and its contents all non-NUL.
NUL-terminate the link name to ensure this doesn't cause further
problems for the kernel.

Cc: Al Viro <[email protected]>
Cc: Andrew Morton <[email protected]>
Signed-off-by: Duane Griffin <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
duaneg authored and Al Viro committed Dec 31, 2008
1 parent 0351468 commit ebd09ab
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -2786,13 +2786,16 @@ int vfs_follow_link(struct nameidata *nd, const char *link)
/* get the link contents into pagecache */
static char *page_getlink(struct dentry * dentry, struct page **ppage)
{
struct page * page;
char *kaddr;
struct page *page;
struct address_space *mapping = dentry->d_inode->i_mapping;
page = read_mapping_page(mapping, 0, NULL);
if (IS_ERR(page))
return (char*)page;
*ppage = page;
return kmap(page);
kaddr = kmap(page);
nd_terminate_link(kaddr, dentry->d_inode->i_size, PAGE_SIZE - 1);
return kaddr;
}

int page_readlink(struct dentry *dentry, char __user *buffer, int buflen)
Expand Down

0 comments on commit ebd09ab

Please sign in to comment.