aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-08-19 21:02:56 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-08-19 21:02:56 -0400
commitcc314eef0128a807e50fa03baf2d0abc0647952c (patch)
tree8e38db1be28006894915273b3f3cb3beaa6efda3 /mm
parent2fb1e3086df9b454538491fba8121298da37cd23 (diff)
Fix nasty ncpfs symlink handling bug.
This bug could cause oopses and page state corruption, because ncpfs used the generic page-cache symlink handlign functions. But those functions only work if the page cache is guaranteed to be "stable", ie a page that was installed when the symlink walk was started has to still be installed in the page cache at the end of the walk. We could have fixed ncpfs to not use the generic helper routines, but it is in many ways much cleaner to instead improve on the symlink walking helper routines so that they don't require that absolute stability. We do this by allowing "follow_link()" to return a error-pointer as a cookie, which is fed back to the cleanup "put_link()" routine. This also simplifies NFS symlink handling. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/shmem.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index e64fa726a790..5a81b1ee4f7a 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1773,32 +1773,27 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
1773 return 0; 1773 return 0;
1774} 1774}
1775 1775
1776static int shmem_follow_link_inline(struct dentry *dentry, struct nameidata *nd) 1776static void *shmem_follow_link_inline(struct dentry *dentry, struct nameidata *nd)
1777{ 1777{
1778 nd_set_link(nd, (char *)SHMEM_I(dentry->d_inode)); 1778 nd_set_link(nd, (char *)SHMEM_I(dentry->d_inode));
1779 return 0; 1779 return NULL;
1780} 1780}
1781 1781
1782static int shmem_follow_link(struct dentry *dentry, struct nameidata *nd) 1782static void *shmem_follow_link(struct dentry *dentry, struct nameidata *nd)
1783{ 1783{
1784 struct page *page = NULL; 1784 struct page *page = NULL;
1785 int res = shmem_getpage(dentry->d_inode, 0, &page, SGP_READ, NULL); 1785 int res = shmem_getpage(dentry->d_inode, 0, &page, SGP_READ, NULL);
1786 nd_set_link(nd, res ? ERR_PTR(res) : kmap(page)); 1786 nd_set_link(nd, res ? ERR_PTR(res) : kmap(page));
1787 return 0; 1787 return page;
1788} 1788}
1789 1789
1790static void shmem_put_link(struct dentry *dentry, struct nameidata *nd) 1790static void shmem_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
1791{ 1791{
1792 if (!IS_ERR(nd_get_link(nd))) { 1792 if (!IS_ERR(nd_get_link(nd))) {
1793 struct page *page; 1793 struct page *page = cookie;
1794
1795 page = find_get_page(dentry->d_inode->i_mapping, 0);
1796 if (!page)
1797 BUG();
1798 kunmap(page); 1794 kunmap(page);
1799 mark_page_accessed(page); 1795 mark_page_accessed(page);
1800 page_cache_release(page); 1796 page_cache_release(page);
1801 page_cache_release(page);
1802 } 1797 }
1803} 1798}
1804 1799