提交 7d6c7045 编写于 作者: M Michael Halcrow 提交者: Linus Torvalds

eCryptfs: remove retry loop in ecryptfs_readdir()

The retry block in ecryptfs_readdir() has been in the eCryptfs code base
for a while, apparently for no good reason.  This loop could potentially
run without terminating.  This patch removes the loop, instead erroring
out if vfs_readdir() on the lower file fails.
Signed-off-by: NMichael Halcrow <mhalcrow@us.ibm.com>
Reported-by: NAl Viro <viro@ZinIV.linux.org.uk>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 9d793b0b
...@@ -71,12 +71,11 @@ struct ecryptfs_getdents_callback { ...@@ -71,12 +71,11 @@ struct ecryptfs_getdents_callback {
void *dirent; void *dirent;
struct dentry *dentry; struct dentry *dentry;
filldir_t filldir; filldir_t filldir;
int err;
int filldir_called; int filldir_called;
int entries_written; int entries_written;
}; };
/* Inspired by generic filldir in fs/readir.c */ /* Inspired by generic filldir in fs/readdir.c */
static int static int
ecryptfs_filldir(void *dirent, const char *name, int namelen, loff_t offset, ecryptfs_filldir(void *dirent, const char *name, int namelen, loff_t offset,
u64 ino, unsigned int d_type) u64 ino, unsigned int d_type)
...@@ -125,18 +124,18 @@ static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir) ...@@ -125,18 +124,18 @@ static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir)
buf.dirent = dirent; buf.dirent = dirent;
buf.dentry = file->f_path.dentry; buf.dentry = file->f_path.dentry;
buf.filldir = filldir; buf.filldir = filldir;
retry:
buf.filldir_called = 0; buf.filldir_called = 0;
buf.entries_written = 0; buf.entries_written = 0;
buf.err = 0;
rc = vfs_readdir(lower_file, ecryptfs_filldir, (void *)&buf); rc = vfs_readdir(lower_file, ecryptfs_filldir, (void *)&buf);
if (buf.err)
rc = buf.err;
if (buf.filldir_called && !buf.entries_written)
goto retry;
file->f_pos = lower_file->f_pos; file->f_pos = lower_file->f_pos;
if (rc < 0)
goto out;
if (buf.filldir_called && !buf.entries_written)
goto out;
if (rc >= 0) if (rc >= 0)
fsstack_copy_attr_atime(inode, lower_file->f_path.dentry->d_inode); fsstack_copy_attr_atime(inode,
lower_file->f_path.dentry->d_inode);
out:
return rc; return rc;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册