From: Duane Griffin Date: Fri, 19 Dec 2008 20:47:12 +0000 (+0000) Subject: vfs: ensure page symlinks are NUL-terminated X-Git-Tag: v2.6.29-rc1~549^2~26 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=ebd09abbd9699f328165aee50a070403fbf55a37;p=linux-2.6-omap-h63xx.git vfs: ensure page symlinks are NUL-terminated 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 Cc: Andrew Morton Signed-off-by: Duane Griffin Signed-off-by: Al Viro --- diff --git a/fs/namei.c b/fs/namei.c index ab441af4196..9ed5e2818f8 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -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)