diff options
author | Trond Myklebust <trond.myklebust@primarydata.com> | 2016-09-20 14:34:24 -0400 |
---|---|---|
committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2016-09-22 17:02:03 -0400 |
commit | 78d04af4995a1358039f4406bd31c28faedfa030 (patch) | |
tree | e46c10072ed05e4a24dc168bd95f8be5f60f3a3d /fs | |
parent | a1d617d8f134679741b0b35e8e1436b015ac5538 (diff) | |
download | linux-stable-78d04af4995a1358039f4406bd31c28faedfa030.tar.gz linux-stable-78d04af4995a1358039f4406bd31c28faedfa030.tar.bz2 linux-stable-78d04af4995a1358039f4406bd31c28faedfa030.zip |
NFS: nfs_prime_dcache must validate the filename
Before we try to stash it in the dcache, we need to at least check
that the filename passed to us by the server is non-empty and doesn't
contain any illegal '\0' or '/' characters.
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/dir.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 177fefb26c18..eb095f77c39d 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -496,6 +496,14 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry) return; if (!(entry->fattr->valid & NFS_ATTR_FATTR_FSID)) return; + if (filename.len == 0) + return; + /* Validate that the name doesn't contain any illegal '\0' */ + if (strnlen(filename.name, filename.len) != filename.len) + return; + /* ...or '/' */ + if (strnchr(filename.name, filename.len, '/')) + return; if (filename.name[0] == '.') { if (filename.len == 1) return; |