diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-09-01 16:06:39 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-09-03 22:50:28 -0400 |
commit | 301f0268b63d1b07268e46f5901fc51d6cac20eb (patch) | |
tree | c4a4986ee8e2da49f5f028f416f71697f041ee93 /fs/nfsd/nfs4xdr.c | |
parent | ca4e05195dbc25bb0f1d4c70a39e6396115807c9 (diff) |
nfsd: racy access to ->d_name in nsfd4_encode_path()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index c2a4701d7286..d9454fe5653f 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -1816,10 +1816,7 @@ static __be32 nfsd4_encode_fs_location4(struct nfsd4_fs_location *location, | |||
1816 | static __be32 nfsd4_encode_path(const struct path *root, | 1816 | static __be32 nfsd4_encode_path(const struct path *root, |
1817 | const struct path *path, __be32 **pp, int *buflen) | 1817 | const struct path *path, __be32 **pp, int *buflen) |
1818 | { | 1818 | { |
1819 | struct path cur = { | 1819 | struct path cur = *path; |
1820 | .mnt = path->mnt, | ||
1821 | .dentry = path->dentry, | ||
1822 | }; | ||
1823 | __be32 *p = *pp; | 1820 | __be32 *p = *pp; |
1824 | struct dentry **components = NULL; | 1821 | struct dentry **components = NULL; |
1825 | unsigned int ncomponents = 0; | 1822 | unsigned int ncomponents = 0; |
@@ -1859,14 +1856,19 @@ static __be32 nfsd4_encode_path(const struct path *root, | |||
1859 | 1856 | ||
1860 | while (ncomponents) { | 1857 | while (ncomponents) { |
1861 | struct dentry *dentry = components[ncomponents - 1]; | 1858 | struct dentry *dentry = components[ncomponents - 1]; |
1862 | unsigned int len = dentry->d_name.len; | 1859 | unsigned int len; |
1863 | 1860 | ||
1861 | spin_lock(&dentry->d_lock); | ||
1862 | len = dentry->d_name.len; | ||
1864 | *buflen -= 4 + (XDR_QUADLEN(len) << 2); | 1863 | *buflen -= 4 + (XDR_QUADLEN(len) << 2); |
1865 | if (*buflen < 0) | 1864 | if (*buflen < 0) { |
1865 | spin_unlock(&dentry->d_lock); | ||
1866 | goto out_free; | 1866 | goto out_free; |
1867 | } | ||
1867 | WRITE32(len); | 1868 | WRITE32(len); |
1868 | WRITEMEM(dentry->d_name.name, len); | 1869 | WRITEMEM(dentry->d_name.name, len); |
1869 | dprintk("/%s", dentry->d_name.name); | 1870 | dprintk("/%s", dentry->d_name.name); |
1871 | spin_unlock(&dentry->d_lock); | ||
1870 | dput(dentry); | 1872 | dput(dentry); |
1871 | ncomponents--; | 1873 | ncomponents--; |
1872 | } | 1874 | } |