提交 331fee3c 编写于 作者: L Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull vfs fixes from Al Viro:
 "A bunch of fixes; the last one is this cycle regression, the rest are
  -stable fodder."

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  fix off-by-one in argument passed by iterate_fd() to callbacks
  lookup_one_len: don't accept . and ..
  cifs: get rid of blind d_drop() in readdir
  nfs_lookup_revalidate(): fix a leak
  don't do blind d_drop() in nfs_prime_dcache()
...@@ -86,14 +86,17 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name, ...@@ -86,14 +86,17 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name,
dentry = d_lookup(parent, name); dentry = d_lookup(parent, name);
if (dentry) { if (dentry) {
int err;
inode = dentry->d_inode; inode = dentry->d_inode;
/* update inode in place if i_ino didn't change */ /* update inode in place if i_ino didn't change */
if (inode && CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) { if (inode && CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) {
cifs_fattr_to_inode(inode, fattr); cifs_fattr_to_inode(inode, fattr);
return dentry; return dentry;
} }
d_drop(dentry); err = d_invalidate(dentry);
dput(dentry); dput(dentry);
if (err)
return NULL;
} }
dentry = d_alloc(parent, name); dentry = d_alloc(parent, name);
......
...@@ -994,16 +994,18 @@ int iterate_fd(struct files_struct *files, unsigned n, ...@@ -994,16 +994,18 @@ int iterate_fd(struct files_struct *files, unsigned n,
const void *p) const void *p)
{ {
struct fdtable *fdt; struct fdtable *fdt;
struct file *file;
int res = 0; int res = 0;
if (!files) if (!files)
return 0; return 0;
spin_lock(&files->file_lock); spin_lock(&files->file_lock);
fdt = files_fdtable(files); for (fdt = files_fdtable(files); n < fdt->max_fds; n++) {
while (!res && n < fdt->max_fds) { struct file *file;
file = rcu_dereference_check_fdtable(files, fdt->fd[n++]); file = rcu_dereference_check_fdtable(files, fdt->fd[n]);
if (file) if (!file)
continue;
res = f(p, file, n); res = f(p, file, n);
if (res)
break;
} }
spin_unlock(&files->file_lock); spin_unlock(&files->file_lock);
return res; return res;
......
...@@ -2131,6 +2131,11 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len) ...@@ -2131,6 +2131,11 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
if (!len) if (!len)
return ERR_PTR(-EACCES); return ERR_PTR(-EACCES);
if (unlikely(name[0] == '.')) {
if (len < 2 || (len == 2 && name[1] == '.'))
return ERR_PTR(-EACCES);
}
while (len--) { while (len--) {
c = *(const unsigned char *)name++; c = *(const unsigned char *)name++;
if (c == '/' || c == '\0') if (c == '/' || c == '\0')
......
...@@ -450,7 +450,8 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry) ...@@ -450,7 +450,8 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry)
nfs_refresh_inode(dentry->d_inode, entry->fattr); nfs_refresh_inode(dentry->d_inode, entry->fattr);
goto out; goto out;
} else { } else {
d_drop(dentry); if (d_invalidate(dentry) != 0)
goto out;
dput(dentry); dput(dentry);
} }
} }
...@@ -1100,6 +1101,8 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags) ...@@ -1100,6 +1101,8 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
out_zap_parent: out_zap_parent:
nfs_zap_caches(dir); nfs_zap_caches(dir);
out_bad: out_bad:
nfs_free_fattr(fattr);
nfs_free_fhandle(fhandle);
nfs_mark_for_revalidate(dir); nfs_mark_for_revalidate(dir);
if (inode && S_ISDIR(inode->i_mode)) { if (inode && S_ISDIR(inode->i_mode)) {
/* Purge readdir caches. */ /* Purge readdir caches. */
...@@ -1112,8 +1115,6 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags) ...@@ -1112,8 +1115,6 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
shrink_dcache_parent(dentry); shrink_dcache_parent(dentry);
} }
d_drop(dentry); d_drop(dentry);
nfs_free_fattr(fattr);
nfs_free_fhandle(fhandle);
dput(parent); dput(parent);
dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n", dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n",
__func__, dentry->d_parent->d_name.name, __func__, dentry->d_parent->d_name.name,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册