Whamcloud - gitweb
LU-1322 llite: revalidate dentry if f_version is 0
authorPeng Tao <tao.peng@emc.com>
Mon, 25 Jun 2012 13:31:18 +0000 (21:31 +0800)
committerJohann Lombardi <johann.lombardi@intel.com>
Tue, 11 Dec 2012 15:03:35 +0000 (10:03 -0500)
If a file is lseek()ed before i_version changes, it is possible
for application to call into ll_readdir and have f_pos pointing
to some garbage data and cause kernel hang.

Signed-off-by: Peng Tao <tao.peng@emc.com>
Change-Id: I49ab94ad5c63c3029d5ad96e27e38e124a135ed8
Reviewed-on: http://review.whamcloud.com/3181
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Lai Siyao <laisiyao@whamcloud.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/llite/dir.c

index 4e94c2a..588929c 100644 (file)
@@ -348,7 +348,8 @@ static int ll_readdir_18(struct file *filp, void *dirent, filldir_t filldir)
         pgoff_t idx         = pos >> CFS_PAGE_SHIFT;
         pgoff_t npages      = dir_pages(inode);
         unsigned chunk_mask = ll_dir_page_mask(inode);
-        int need_revalidate = (filp->f_version != inode->i_version);
+        int need_revalidate = (filp->f_version == 0 ||
+                               filp->f_version != inode->i_version);
         int rc              = 0;
         int done; /* when this becomes negative --- stop iterating */